06-11-2018 10:21 PM
How do I assign values to the values within macro variables which I want to be variables in turn?
For example, let's say I assign a number of question codes:
input question_code $25.;
proc sql noprint;
select question_code into: questioncodelist separated by ' '
So, from here, how do I assign a value to QUESTION_CODE001? In other words, I want to make the values within question_code be variables unto which I can assign values to.
06-11-2018 11:31 PM
data question_vars; input question_code $25.; datalines; QUESTION_CODE001 QUESTION_CODE002 QUESTION_CODE003 run; proc sql noprint; select catt('&',question_code) into: questioncodelist separated by ' ' from question_vars; quit; %let question_code001=a; %let question_code002=b; %let question_code003=c; %put &=questioncodelist;
QUESTIONCODELIST=a b c
06-11-2018 11:51 PM
Thank you very much for your reply!
I'm finding this one hard to put into words to be honest.
Basically I would like to be able to read through a dataset and I would like to make the value of a variable, in turn be another variable which I can assign another value to.
For example let's say an observation contains:
Columns: var1 var2 var3
Row 1 contents: AAA BBB CCC
So as I am reading through var1, I would like to be able to make its value i.e. AAA in turn be a variable name to which I can assign var3.
In other words:
let the value of (var1) = the value of var3
so that new variable AAA = CCC.
06-12-2018 12:03 AM
Maybe this then?
data _null_; retain VAR1 'AAA' VAR3 'CCC'; call symputx(VAR1, VAR3); call execute('%put &='||VAR1); run;