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 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!

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
  • 1373 views
  • 0 likes
  • 2 in conversation