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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.