sas - do loop within data step with unresolve varialbes -
i have several parameters proc sql select into: , store of them dataset named parm. following code attempted:
i got following parameter previous step:
%let count = 4; %let yymm1 = '1505'; %let yymm2 = '1504'; %let yymm3 = '1503'; %let yymm4 = '1502'; here data step:
data parm; format yymm1 - yymm&count. $4.; array a(*) yymm1-yymm&count.; = 1 &count.; a(i) = "&&yymm&i"; end; run; problem &i , &&yymm cannot resolved.
while echo @joe 's comment, here suggestions on given situation. first make sure if macro variable values contain single quotes or not. have in macro variable definition, while length=4 in data step won't cut you. @joe suggested, need separate macro variable , data step variable doing following:
%let count = 4; %let yymm1 = '1505'; %let yymm2 = '1504'; %let yymm3 = '1503'; %let yymm4 = '1502'; data parm; format yymm1 - yymm&count. $6.; array a(*) yymm1-yymm&count.; = 1 &count.; a(i) = symget(cats('yymm',i)); end; run;
Comments
Post a Comment