Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Problem parsing strings that contain "$CHAR"

From   "Nick Cox" <>
To   <>
Subject   st: RE: Problem parsing strings that contain "$CHAR"
Date   Tue, 20 Apr 2010 20:10:47 +0100

Try using \$ to indicate literal $ characters. 


I have to parse the lines of SAS syntax files that contain 1) the
position of a variable in a raw data file, 2) the name of the variable,
and 3) the data type of the variable. Examples of such lines are:

@04075    Variable_B    $5.
@04080    Variable_C    $CHAR6.

Both "$#" and "$CHAR#" mean that the variable is a string variable of #
characters. I have no problem parsing the first line above, but am
looking for advice on what to do with lines that contain a sequence like
"$CHAR6". Such sequences appear to be evaluated first and before the
string is parsed, and results in "", as in below:

. loc line @04080    Variable_C    $CHAR6.
. di "`line'"
@04080    Variable_C    .

Commands like regexm and tokenize or functions like subinstr also see
"." instead of "$CHAR6.", making it impossible (for me at least) to
retrieve all the relevant information in these lines. 
Wednesday 9 June, 11.30 am 	Staff/Student photograph

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index