BookmarkSubscribeRSS Feed
deleted_user
Not applicable
When Im trying to submit the following code to combine the monthly data, SAS returns only the infos from the first month with log 'NOTE: LOST CARD.
i=2 lastobs=1 Flight=IA11101 Origin=HND Dest=SFO Date=14883 RevCargo=182886 _ERROR_=1 _N_=1'. What the hell is wrong with that?





data temp1 (drop=i);
%let n=9;
do i=1 to 3;
do until (lastobs);
infile "C:\Documents and Settings\Administrator\Desktop\SASPROG3data\prog3_v8\month&n..dat" end=lastobs;
input Flight $ Origin $ Dest $ Date : date9. RevCargo : comma15.2;
output;
end;
%let n=%eval(&n+1);
end;
stop;
run;
1 REPLY 1
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Firstly, you appear to be mixing SAS macro language constucts (the %LET macro variable assignments) with DATA step logic -- the SAS %LET statement will be resolved at SAS compile time, not with each iterative DATA step pass. Or possibly you are not sharing all SAS code, maybe, such as the surrounding %MACRO and %MEND statements necessary with a %DO %END looping technique.

Recommending reading up on the SAS MACRO facility documentation if you intend to execute your DATA step "n" times, once for each INFILE specification. Also, I noticed you may be intending to read several input files in a single DATA step execution -- which is quite possible, however you will either need to reset your lastobs variable to zero with each DO UNTIL(lastobs); END; execution -- SAS will not reset the variable for you -- another suitable technique is to change your END= SAS variable to make it unique for each %DO %END macro execution.

Scott Barry
SBBWorks, Inc.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 950 views
  • 0 likes
  • 2 in conversation