08-24-2012 09:12 AM
I have the following need.
I have a varible XXX and I would save the value of this variable in an external file. If I do something like this:
The file is empty and if I do this
I get an error. Do there is a way to save the value of a variable in a file?
08-24-2012 09:37 AM
If variable XXX comes from a dataset, you should refer to it (i.e. SET MYDATASET; ) . If it is a macro variable, you should assign it to a variable (i.e. XXX="&XXX"; put XXX; ) or use quotes in the put statement (i.e. put "&XXX"; )
08-24-2012 10:23 AM
Hi: As PG has explained, you must point to a SAS dataset in order to use a variable name in a PUT statement (unless you are creating the variable in your program).
The program below writes the NAME variable from SASHELP.CLASS to a flat file for only the students with an AGE that is GE 15.
where age ge 15;
Then if you open MYFLATFILE.TXT with Notepad, you will see the 5 students with ages greater than or equal to 15 in SASHELP.CLASS: