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

Hi I am passing 3 parameters from a table in the data step and passing them to a macro.  The parameter 'newtblname1' is working fine it gets the first observation then the 2nd. However the 'var1' and 'var2' it only gets the first observation and does not change on the second.  I think the statement is wrong.  I know i probably don't need the & signs because they are attributes of the dbtblnames_complete table , but i get an error when I don't have the &.  What I am doing incorrectly?

391 data final_validation;
392     set dbtblnames_complete;
393     /*tablename=newtblname1;*/
394     /*******************/
395     /* check 1 :determine if certain columns exist in the table and populate a table value indicating whether they are or not*/
396     colexist = dosubl('%deterifcolsexist(&var1,&var2,' || strip(newtblname1) || ')');
397     contactdtpresent = symget('contactdt');
398     externidpresent = symget('extrnlid');
399     /*********************/
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Where are the values for the first two arguments for the macro %deterifcolsexist() supposed to come from?

Right now you tell it to use the values of macro variables named VAR1 and VAR2 that I do not see you defining anywhere.

The only way the values of those macro variables could possibly change is if the macro itself changed them.  

 

If you want the values to come from observations in the input dataset dbtblnames_complete then you need to reference those variables in your code.  Just like you are referencing the variable NEWTBLNAME1.

 

So if VAR1 and VAR2 are variables in dbtblnames_complete then your code might look like:

 

colexist = dosubl(cats('%deterifcolsexist(',var1,',',var2,',',newtblname1,')'));

Now if &VAR1 and &VAR2 contain the NAMES of variables in the dataset then the code should look like:

colexist = dosubl(cats('%deterifcolsexist(',&var1,',',&var2,',',newtblname1,')'));

 

Also are the values of the macro variables contactdt and extrnlid being changed by that macro call? Seems strange for a macro with that name.  If not why did you include those lines in your example code?

 

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Where are the values for the first two arguments for the macro %deterifcolsexist() supposed to come from?

Right now you tell it to use the values of macro variables named VAR1 and VAR2 that I do not see you defining anywhere.

The only way the values of those macro variables could possibly change is if the macro itself changed them.  

 

If you want the values to come from observations in the input dataset dbtblnames_complete then you need to reference those variables in your code.  Just like you are referencing the variable NEWTBLNAME1.

 

So if VAR1 and VAR2 are variables in dbtblnames_complete then your code might look like:

 

colexist = dosubl(cats('%deterifcolsexist(',var1,',',var2,',',newtblname1,')'));

Now if &VAR1 and &VAR2 contain the NAMES of variables in the dataset then the code should look like:

colexist = dosubl(cats('%deterifcolsexist(',&var1,',',&var2,',',newtblname1,')'));

 

Also are the values of the macro variables contactdt and extrnlid being changed by that macro call? Seems strange for a macro with that name.  If not why did you include those lines in your example code?

 

Gayle
Quartz | Level 8
Hi thanks, no I am not changing contactdt and extrnlid are not being changed I guess i should not have included those lines.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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