BookmarkSubscribeRSS Feed
xiaoys0725
Fluorite | Level 6

Hello, 

 

I am practicing filevar= option. I tried to mock the code in the advanced certification preparation book and the code is as below:

 

data work.sample;
do number=0,1,2;
nextfile="C:/CT/try/data/sample"!!compress(put(number,2.)!!".txt",'');
infile temp filevar=nextfile end=lastobs;
input ID one $ two $ three $;
output;
end;
stop;
run;

 

It works well. 

 

Then I am thinking about what will happen if I replace the temp by a fileref, so the code becomes:

 

filename xyz 'C:/CT/try/data/sample0.txt';
data work.sample3;
do number=1,2;
nextfile="C:/CT/try/data/sample"!!compress(put(number,2.)!!".txt",'');
infile xyz filevar=nextfile end=lastobs;
input ID one $ two $ three $;
output;
end;
stop;
run;

 

and then I got the following log:

 

The infile XYZ is:
Filename=C:\CT\try\data\sample1.txt,
RECFM=V,LRECL=32767,File Size (bytes)=706,
Last Modified=15Sep2017:15:13:54,
Create Time=15Sep2017:15:13:54

NOTE: The infile XYZ is:
Filename=C:\CT\try\data\sample2.txt,
RECFM=V,LRECL=32767,File Size (bytes)=220,
Last Modified=15Sep2017:15:14:20,
Create Time=15Sep2017:15:14:20

NOTE: 1 record was read from the infile XYZ.
The minimum record length was 30.
The maximum record length was 30.
NOTE: 1 record was read from the infile XYZ.
The minimum record length was 30.
The maximum record length was 30.
NOTE: The data set WORK.SAMPLE3 has 2 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.07 seconds
cpu time 0.04 seconds

 

So why does this happen? Is it OK to use a fileref to replace the temp usually? 

 

Thank you!

 

 

7 REPLIES 7
xiaoys0725
Fluorite | Level 6

Thank you! Can I use any placeholder though? I replaced by something casually but I still have the length limit

PGStats
Opal | Level 21

Log lines like

 

NOTE: 1 record was read from the infile XYZ.
The minimum record length was 30.
The maximum record length was 30.

 

is just information about your file. It doesn't signal any problem. Unless, of course, your file has records that aren't 30 characters long.

PG
xiaoys0725
Fluorite | Level 6

Ohhhh Ok, thank you!!

PGStats
Opal | Level 21

When used with filevar, the fileref is just a placeholder, It is ignored.

PG
xiaoys0725
Fluorite | Level 6

But there is a maxim record length so I cannot have the same output as the first one. 

 

And can I use any placeholder? I replaced it by something casually but I still have the length limit

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1269 views
  • 0 likes
  • 3 in conversation