BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
sasuser_8
Obsidian | Level 7

From this example,

 

PROC SQL;

SELECT
CODE_VAR1,
CODE_VAR2,
CODE_VAR3,
CODE_VAR4,
CODE_VAR5,
VAR1,
VAR2,
VAR3,
VAR4,
VAR5

FROM SALE;

QUIT;
RUN; 

 

 

 

I would like to know if it is possible not to repeat the name of the variables, as we can do with a KEEP in a DATA step: CODE_VAR1-CODE_VAR15  VAR1-VAR5  ?

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

Just add a KEEP = option to your SALE dataset and change your SELECT to SELECT *.

View solution in original post

4 REPLIES 4
A_Kh
Barite | Level 11

Hi, 
I think this paper can answer your question. 

SASKiwi
PROC Star

Just add a KEEP = option to your SALE dataset and change your SELECT to SELECT *.

PaigeMiller
Diamond | Level 26

Why would you want to use SQL to select specific columns from an existing data set and do nothing else in SQL?

 

If you are planning to run the data through another PROC after SQL.

 

proc means data=sale(keep=code_var1-code_var5 var1-var5);
/* More PROC MEANS code */
run;

 

As always, context is important, the best approach depends on context, and you haven't given us the slightest hint about why you are doing this.

--
Paige Miller

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2319 views
  • 4 likes
  • 5 in conversation