f



file name contains a macro variable

Is it possible to include a macro variable as part of a file name to be
imported or exported? For example, can I replace the file name "199301.txt"
using a name that includes the macro variable, tstm?

Also, when I define another macro variable, nsks, is it possible to define
it to be a result of a function? In the program, nsks = 33 = nrow(studyid).


%let tstm = 199301;
%let nsks = 33;

DATA id_&tstm;
  INFILE 'C:\199301.txt';
  INPUT id;
RUN;

Thank you very much!
0
hzhou3 (39)
8/14/2004 10:56:48 PM
comp.soft-sys.sas 142827 articles. 3 followers. Post Follow

1 Replies
420 Views

Similar Articles

[PageSpeed] 28

Haigang Zhou wrote:
> Is it possible to include a macro variable as part of a file name to
> be imported or exported? For example, can I replace the file name
> "199301.txt" using a name that includes the macro variable, tstm?

Absolutely.
%let ZhouVar = 199301.txt;
....
infile "&ZhouVar.";

The macro resolution (&) must be inside double quotes.  When inside single
quotes, the & is treated as the ampersand character and not as the start of
macro variable resolution token.

>
> Also, when I define another macro variable, nsks, is it possible to
> define it to be a result of a function? In the program, nsks = 33 =
> nrow(studyid).

Yes.
If in DATA Step, use call symput.
call symput ('ZhouVar', log10(100));

In in macro environment you can use
%sysfunc() to execute a function -or-
%sysevalf() to perform math

-- 
Richard A. DeVenezia
Done being productive? Try SAS Tetris.
http://www.devenezia.com/downloads/sas/af?topic=27


0
radevenz (1543)
8/15/2004 1:19:27 AM
Reply: