BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
robertrao
Quartz | Level 8

Hi,

When I run this code I get an error

Apparent symbolic reference DSET not resolved

Could you help me overcome this??

options symbolgen mlogic;

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

You cannot refer to the value of local macro variables (all macro parameters are local to the macro) outside of the macro.  So you cannot refer to them in the call to the macro.

You would be better off just copying the text twice or using another line of code in the calling program to create a macro variable.

%let name=vent7w2011May ;

%ventilator(dset=&name, itb_extb=intext.combined&name);



View solution in original post

16 REPLIES 16
Tom
Super User Tom
Super User

You cannot refer to the value of local macro variables (all macro parameters are local to the macro) outside of the macro.  So you cannot refer to them in the call to the macro.

You would be better off just copying the text twice or using another line of code in the calling program to create a macro variable.

%let name=vent7w2011May ;

%ventilator(dset=&name, itb_extb=intext.combined&name);



robertrao
Quartz | Level 8

Hi Tom,

Could you clarify this a little bit for me...

the dset changes for every call of the macro so I cannot put it in the %let as well??????

Ron_MacroMaven
Lapis Lazuli | Level 10

Do you have a list of data sets to process?

http://www.sascommunity.org/wiki/Making_Lists

robertrao
Quartz | Level 8

Hi Thanks for the reply I think I got it..

But could you tell me how can I use Set statement to acheive this same thing??

This is inside of a macro and each time you call a macro the results I get I want to append to the previous

Thanks

proc append base=intext.final_all data=intext.&itb_extb;

run;


Tom
Super User Tom
Super User

proc append base=intext.final_all data=intext.&itb_extb;

run;

Says to append the records from intext.&itb_extb to the end of intext.final_all.


You can do the same with a data step like:

data intext.&itb_extb  ;

  set intext.&itb_extb  intext.final_all ;

run;

robertrao
Quartz | Level 8

i have a little confusion here

would it not be :

data intext.final_all ;

  set intext.final_all  intext.&itb_extb ;

run;

robertrao
Quartz | Level 8

Does it matter at all?either way works??

Thanks

Tom
Super User Tom
Super User

Doesn't really matter. The only difference would be order of the records in the table.

The disadvantage of using this method is that as the FINAL_ALL table grows this step will get slower and slower as it has to keep copy over all of the previous records.  The discussion before about placing the names into a macro variable or list of macro variables and then looping over the macro variables to generate a single SET statement that listed all of the datasets would execute faster.  But it depends on the size of the tables whether the difference is significant for your application.

robertrao
Quartz | Level 8

But Tom

in the example below

for the first call this is OK

In the second call  intext.&itb_extb changes and  intext.final_all  has nothing prior

So we will be having the contents of only the dataset in the second call???

Please correct me

In the end we will have only the records from the last dataset???

data intext.&itb_extb  ;

  set intext.&itb_extb  intext.final_all ;

run;

Tom
Super User Tom
Super User

You are right. I reversed the BASE and DATA table names.  The order in the SET statement doesn't matter very much, but which one is specified in the DATA statement is critical.

robertrao
Quartz | Level 8

Thanks Tom for the clarification..

Regards

robertrao
Quartz | Level 8

So, Instead of

data intext.final_all ;

  set intext.final_all  intext.&itb_extb;

   run;

YOU PUT

data intext.&itb_extb  ;

  set intext.&itb_extb  intext.final_all ;

run;

In both of these the first one is to be followed right???


robertrao
Quartz | Level 8

Hi,

I tried to use it and either of the cases it says:

intext.final_all ; doesnot exist??????

Please let me know how to deal with this???

Thanks

Tom
Super User Tom
Super User

In any of these accumulation type programs you need to "prime the pump" in some way.  That is one of the advantages of using PROC APPEND as it is happy to handle the case when the BASE dataset does not already exist.

One way to deal with it is to add some logic to your macro.  Such as by making the inclusion of the final dataset conditional on it already existing as in the code fragment below.

data intext.final_all ;

  set

%if exist(intext.final_all) %then intext.final_all ;

   intext.&itb_extb ;

run;

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 16 replies
  • 1263 views
  • 7 likes
  • 3 in conversation