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 ?
Just add a KEEP = option to your SALE dataset and change your SELECT to SELECT *.
Hi,
I think this paper can answer your question.
Just add a KEEP = option to your SALE dataset and change your SELECT to SELECT *.
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.
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!
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.