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

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.

 

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
  • 1256 views
  • 0 likes
  • 3 in conversation