%Let Datalib = 'My-Libname\';
Filename Datalib "&Datalib." ;
%Macro Dummy ( Name = , N = );
Data _Null_;
InFile DataSeq Pad ;
File Datalib (&Name) ;
Format Name $CHAR08. ;
Format ID $CHAR02. ;
Input ID 01-02
Name 20-27 ;
If _N_ GT &N
And ID EQ './'
Then Stop;
If _N_ GT &N
Then Put _INFile_;
Run;
%Mend ;
%DUMMY ( NAME = Name
, N = 1);
Run;
NOTE: 4 records were read from the infile DATASEQ.
The minimum record length was 26.
The maximum record length was 96.
NOTE: A total of 2 records were written to the file library DATALIB.
The minimum record length was 256.
The maximum record length was 256.
NOTE: 2 records were written to the file DATALIB(NAME).
The minimum record length was 256.
The maximum record length was 256.
Creates file 'Name.dat', but I need NAME only. It works fine by older SAS versions.
What is your current SAS version?
What was the older SAS version?
According to the doc http://support.sas.com/documentation/cdl/en/hostwin/69955/HTML/default/viewer.htm#n07buc7sg08fdrn1c1..., it is works as documented.
I suggest to use
%let datalib = c:\temp;
%let name = sugus;
data _null_;
file "&datalib\&name";
put "some text";
run;
Proper formatting of code really makes life easier. Please compare this functionally equivalent code:
%let datalib = 'My-Libname\';
filename datalib "&datalib.";
%macro dummy(name=, n=);
data _null_;
infile dataseq pad;
file datalib (&name);
format
Name $char08.
ID $char02.
;
input
ID 01-02
Name 20-27
;
if _n_ gt &n
then do;
if ID eq './'
then stop;
else put _infile_;
end;
run;
%mend ;
%dummy(name = Name, n = 1);
to your original post. Mind that I converted uppercase to lowercase in all places where uppercase does not have an effect and only makes reading the code harder.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.