I'm the administrator of the data warehouse server, the main developer, and third-level support.
I'm also the primary contact for our SAS power-users.
My rather rich background in UNIX admin, operating and programming has been of value.
assuming you would do the same within a macro:
data want (drop=country rename=(tmp=country)); length tmp $2000; set have end=last; retain tmp; tmp=catx(",",tmp,country); if last then output; run;
I changed the code as it follows:
data want (drop=&var. rename=(tmp=&var.)); length tmp $2000; set have end=last; retain tmp; tmp=catx(",",tmp,&var.); if last then output; run;
do you already notice a mistake? Instead of getting the value list I get the variable name....
What does &avatar resolve to? And what are you getting?
I don't see any issues with the code.
PS. I didn't mean any offence with previous response 🙂
1. I have a macro which is based on the variable &var;
2. A call execute is used;
If for istance the &var assume the variable "segment", I did not get as output the values assumed by the variable "segment" but only the name of the variable "segment" itself.
The example works perfectly, but when I switched to the macro I did something wrong.
I don't have enough info to help.
I think ink this may warrant a new question now, with more details. Usually with call execute it becomes an issue of timing - when it executes versus values that are passed.
ok, fair enough. I will keep trying and in case I will post something new.
If you want to use the macro variable to refer to a variable then it needs to contain the NAME of the variable.
%let var=segment;
From the symptom it looks like you have set the macro variable to a value that includes quotes.
%let var="segment";
This will be interpreted by regular SAS as a string literal and not the name of a variable.
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.