BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tasha89tp
Calcite | Level 5

 

So, I imported the file:

 

PROC IMPORT DATAFILE = 'C:\Users\...xlsx' DBMS = XLSX OUT = general

 

I need to make two datasets from general (gss1 and gss2) both consisting of 8 variables when general has 20.

 

How do you create a dataset with certain variables from an excel file after you proc import datafile?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

You use the KEEP statement.

 

See below where two datasets are created, one with Name/Age/Sex and second with Name/Weight/Height. 

When you create the datasets, it's likely you'll want a common variable between the two so you can map back to records if required.

 

data class1;
set sashelp.class;

keep name age sex;
run;

data class2;
set sashelp.class;
keep name weight height;
run;

View solution in original post

1 REPLY 1
Reeza
Super User

You use the KEEP statement.

 

See below where two datasets are created, one with Name/Age/Sex and second with Name/Weight/Height. 

When you create the datasets, it's likely you'll want a common variable between the two so you can map back to records if required.

 

data class1;
set sashelp.class;

keep name age sex;
run;

data class2;
set sashelp.class;
keep name weight height;
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 1244 views
  • 0 likes
  • 2 in conversation