Hi All,
I have columns 1-n in have table ( like COL1 COL2 COL3 COL3 COL4 COL5 COL6). I want to write like this (keep=COL(1-n). Instead of writing (keep=COL1 COL2 COL3 COL3 COL4 COL5 COL6).
because I want to select 3 columns in 1 table and 10 columns in another table.
data test(keep=COL1 COL2 COL3 COL3 COL4 COL5 COL6);
set have;
run;
when using lists you need OF keyword to concat
data cc(keep=COl: )
set x;
a=cat(of col: )
ru
Do you mean a shorter way?
data test(keep=COL1-COL6);
set have;
run;
data test(keep=COL:);
set have;
run;
Variable Lists
data Test (keep = col1-col6);
data Test (keep = col:);
@sathya66 wrote:
Hi All,
I have columns 1-n in have table ( like COL1 COL2 COL3 COL3 COL4 COL5 COL6). I want to write like this (keep=COL(1-n). Instead of writing (keep=COL1 COL2 COL3 COL3 COL4 COL5 COL6).
because I want to select 3 columns in 1 table and 10 columns in another table.
data test(keep=COL1 COL2 COL3 COL3 COL4 COL5 COL6);
set have;
run;
data cc(keep=COL:);
set x;
a=cat(COL:); /*error */
run;
Please paste your code into a code box, otherwise emojis invade.
Check the link I included in my answer for examples to your new question.
@sathya66 wrote:
Thanks,
data Test (keep = col:); this way
and also I want to concatenate the variables in a single variable .
data cc(keep=COL:);
set x;
a=cat(COL:); /*error */
run;
when using lists you need OF keyword to concat
data cc(keep=COl: )
set x;
a=cat(of col: )
ru
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.