Hi,
I need to add brackets for a list of numerical variables. It seems that the concatenation doesn't work in an ARRAY statement.
This kind of data step doesn' work:
data temp2;
set temp1;
array A(*) cat1-cat&N_cat;
array B(*) &level._se1-&level._se&N_cat;
do j=1 to dim(A);
B(j)=cats('(',A(j),')');
end;
run;
Because the number of variables to adapt can change, I thought to use an array statement.
Maybe with a proc format ?
Thanks for your help
Then, how about?:
%let N=3;
data temp2 (drop=j);
set temp1;
array A(*) cat1-cat&N.;
array B(&N.) $;
do j=1 to &N.;
B(j)=cats('(',A(j),')');
end;
run;
An example dataset would help people to respond, as well as your macro variable assignments.
Also, do the variables &level._se1-&level._se&N_cat
exist or are they new variables that you are trying to create?
&level._se1-&level._se&N_cat are new variables.
&N_cat is a number which changes.
For example;
data temp1;
input num cat1 cat2 cat3;
datalines;
1 3.35 5.36 9.25
2 5.32 1.20 1.25
;
run;
I would like to put cat1 cat2 cat3 between brackets.
Then, how about?:
%let N=3;
data temp2 (drop=j);
set temp1;
array A(*) cat1-cat&N.;
array B(&N.) $;
do j=1 to &N.;
B(j)=cats('(',A(j),')');
end;
run;
I works ! Thanks a lot.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.