BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sathya66
Barite | Level 11

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

when using lists you need OF keyword to concat

 

data cc(keep=COl: )
set x;
a=cat(of col: )
ru

View solution in original post

7 REPLIES 7
novinosrin
Tourmaline | Level 20

Do you mean a shorter way?

 

 

data test(keep=COL1-COL6);

set have;

run;

rajeshalwayswel
Pyrite | Level 9

data test(keep=COL:);

set have;

run;

Reeza
Super User

Variable Lists

 

data Test (keep = col1-col6);

data Test (keep = col:);

http://documentation.sas.com/?docsetId=lrcon&docsetTarget=p0wphcpsfgx6o7n1sjtqzizp1n39.htm&docsetVer...

 


@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;

 


 

sathya66
Barite | Level 11
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;

sathya66
Barite | Level 11
data cc(keep=COL:);
set x;
a=cat(COL:); /*error */
run;
Reeza
Super User

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;


 

novinosrin
Tourmaline | Level 20

when using lists you need OF keyword to concat

 

data cc(keep=COl: )
set x;
a=cat(of col: )
ru

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1507 views
  • 0 likes
  • 4 in conversation