DATA Step, Macro, Functions and more

Create a subset by variable type

Accepted Solution Solved
Reply
Regular Contributor
Posts: 199
Accepted Solution

Create a subset by variable type

Is there a way to use a DATA step to create a subset of only the numeric, or character, variables in a dataset?

 

Thanks.


Accepted Solutions
Solution
‎02-20-2016 10:59 PM
Super User
Posts: 17,818

Re: Create a subset by variable type

What do you mean? 

 

You can use _numeric_ or _character_ to reference all numeric or character variables. 

 

Data num_vars;
Set have;

Keep _numeric_;
Run;

View solution in original post


All Replies
Solution
‎02-20-2016 10:59 PM
Super User
Posts: 17,818

Re: Create a subset by variable type

What do you mean? 

 

You can use _numeric_ or _character_ to reference all numeric or character variables. 

 

Data num_vars;
Set have;

Keep _numeric_;
Run;
Super User
Posts: 9,676

Re: Create a subset by variable type

Data num_vars;
Set sashelp.class(keep=_numeric_);
Run;
☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 199 views
  • 2 likes
  • 3 in conversation