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: Call for Content

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!

Submit your idea!

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