i have 10000 variable and i want to keep only 500 variable.
without using keep drop
@aanan1417 wrote:
i have 10000 variable and i want to keep only 500 variable.
without using keep drop
WHY?
The only other method I can think of is to explicitly name each of your columns in a SELECT statement in SQL.
proc sql;
create table want as
select name, age
from sashelp.class;
quit;
If you have naming conventions or patterns you can generate your variable lists dynamically or use variable short cut lists but those cannot be used in SQL.
Here is a reference that illustrates how to refer to variables and datasets in a short cut list:
https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html
@aanan1417 wrote:
i have 10000 variable and i want to keep only 500 variable.
without using keep drop
WHY?
The only other method I can think of is to explicitly name each of your columns in a SELECT statement in SQL.
proc sql;
create table want as
select name, age
from sashelp.class;
quit;
If you have naming conventions or patterns you can generate your variable lists dynamically or use variable short cut lists but those cannot be used in SQL.
Here is a reference that illustrates how to refer to variables and datasets in a short cut list:
https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html
@Reeza wrote:
@aanan1417 wrote:
i have 10000 variable and i want to keep only 500 variable.
without using keep drop
WHY?
The only other method I can think of is to explicitly name each of your columns in a SELECT statement in SQL.
A real kludgy method is create a separate data set with the desired named variables of the proper types and use Proc Append with Force. Not that I advocate such, but it is a way that meets OP somewhat problematic requirement. Probably way more work than proper variable lists with drop and keep.
@aanan1417 could share a proc contents with Order=Varnum output and indicate which variables he wants.
Hi @aanan1417,
To help you, we will need more information, e.g.:
Edit: If you have a SAS data you could write it out to a file (e.g., proc export) and just read in the information you want from that file, but again the requirement to not use drop or keep, means there is more code (and I/O in this case) than is necessary.
Thanks & kind regards,
Amir.
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.