Programming the statistical procedures from SAS

Create a SAS dataset

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Create a SAS dataset

[ Edited ]

 

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?

 


Accepted Solutions
Solution
‎12-12-2016 01:43 AM
Super User
Posts: 18,586

Re: Create a SAS dataset

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


All Replies
Solution
‎12-12-2016 01:43 AM
Super User
Posts: 18,586

Re: Create a SAS dataset

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;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

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