Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: Problem parsing strings that contain "$CHAR"


From   <benoit.hebert@hrsdc-rhdcc.gc.ca>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Problem parsing strings that contain "$CHAR"
Date   Tue, 20 Apr 2010 15:01:51 -0400

Dear Stata users,

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. 

Any help appreciated,

Benoit-Paul Hebert
Recherche en politiques / Policy Research
RHDCC/HRSDC

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index