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 /*********************/
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?
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?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.