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.

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
  • 1 reply
  • 584 views
  • 0 likes
  • 2 in conversation