Hello,
I have a data set that I'd like to have a few column concatenated into one colum. The data set and variables are like this:
(10 variables)
department item cat1 cat2 cat3 cat4 cat5 nt1 nt2 nt3 aaa v 1a 2a 3a 4a 5a 1a 2a bbb w 1b 2b 3b 1b 2b 3b ccc x 1c 2c 3c 4c 1c 2c 3c ddd y 1d 2d 3d 4d 5d 1d 2d 3d
The end table should look like this (3 variables):
department item newvar aaa v 1a, 2a, 3a, 4a, 5a, 1a, 2a bbb w 1b, 2b, 3b, 1b, 2b, 3b ccc x 1c, 2c, 3c, 4c, 1c, 2c, 3c ddd y 1d, 2d, 3d, 4d, 5d, 1d, 2d, 3d
These cat and nt variables are obtained by joining two tables (catTable and ntTable) so we have the option of working with one table at a time and concatenating twice, but the number of cat and nt variables can vary at any time so concatenating needs to be dynamic.
I thought about using this SAS option to create a macro but didn't know how to make the macro variable work. Thanks in advance for your help.
dsid1 = open("catTable");
dsid2 = open("ntTable");
&num_cat = attrn(dsid1,"NVARS")-2;
&num_nt = attrn(dsid2,"NVARS")-2;
... View more