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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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