BookmarkSubscribeRSS Feed
Michael_W
Calcite | Level 5
I am stuck and I am hoping one of the many SAS guru can assist me. I am trying to dymanically generate several .sas files that are incrementally named (e.g. PRG01.SAS, PRG02.SAS, etc.) and each of which contains slightly different contents (e.g. PRG01.SAS contains Data WORK.TMP01; Set MYTBL (FirstObs=1 OBS=1000000); run; and PRG02.SAS contains Data WORK.TMP01; Set MYTBL (FirstObs=10000001 OBS=2000000); run;)

The FIRSTOBS and OBS values are calculated based on a macro variable value that I compute in two prior DATA STEPs using a CALL SYMPUT. I then attempt to pass those values to my macro (which is were I think the breakdown is occuring) which it uses to calcute the FIRSTOBS and OBS values for each iteration of a %DO loop. Inside the loop, I am also opening the ODS buffer to spool off statement to the dynamically named .SAS files mentioned above.

Any ideas on what I am doing wrong?
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Suggest you share some code and explain exactly what error (or undesirable result) you are getting. When deriving SYMPUT, there are resolution issues that can occur, so you always want to end each DATA (and PROC for my own opinion) with a RUN; statement, so SAS performs the compilation up to the current point in the code execution, even within a macro.

Also, consider writing a general purpose (as in one resuable) macro and re-execute it as needed passing any necessary parameters.

Scott Barry
SBBWorks, Inc.
Michael_W
Calcite | Level 5
Thanks Scott. Great suggestion. I will definitely keep that in mind down the road. Shortly after posting my issue, I figured out what my problem was (I was using single quotes when I should have used double quotes). That simple oversight ultimately did the trick! Thanks for responding so quickly.

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
  • 2 replies
  • 694 views
  • 0 likes
  • 2 in conversation