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
Lapis Lazuli | Level 10

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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1154 views
  • 4 likes
  • 5 in conversation