SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

subsetting

Reply
Occasional Contributor
Posts: 7

subsetting

 I have a dataset as below. I want to keep the value based on the “studyeye”. For example, if it is OD in “studyeye", I keep only the value from “PrevIOP_OD_1". How can I do that in SAS studio?

 


Screen Shot 2016-12-01 at 2.25.23 PM.png
Super Contributor
Posts: 266

Re: subsetting

Posted in reply to superbibi

It is insterting problem, what I understand you want to control the column in output dataset based on the value in the table. 

 

In below example, I tried to keep only column Type when Make='Audi'.

 

data cars ;
set sashelp.cars(obs=10);
run;

%macro control_column(cond=,keep_list=);
data cars_new;
set cars;
where &cond;
keep &keep_list;
run;
%mend;

%control_column(cond=Make='Audi', keep_list=Type);
Occasional Contributor
Posts: 7

Re: subsetting

Thank you Rahul. Do you keep the whole column or just some values in the column? I want to keep only some value of the column. Could you upload part of the dataset?

Super Contributor
Posts: 266

Re: subsetting

Posted in reply to superbibi

You can execute the above code in SAS studio and see if you are getting desired result.

Super User
Posts: 19,877

Re: subsetting

Posted in reply to superbibi

Based on your data what would you expect as your output?

Occasional Contributor
Posts: 7

Re: subsetting

I want to have only the PrevIOPOD_1/PrevIOPOS_1 values based on the studyeye.

I come up with a maybe easier solution. I can split the dataset based on the sutdyeye into two subdatasets. Then I can keep one of the PrevIOPOS_1/PrevIOPOS_1. then I combine them again. 

Trusted Advisor
Posts: 1,022

Re: subsetting

Posted in reply to superbibi

You have shown us the source table.   Now show us explicitly what the result table would look like.

Occasional Contributor
Posts: 7

Re: subsetting


Screen Shot 2016-12-05 at 11.19.15 AM.png
Contributor
Posts: 22

Re: subsetting

Posted in reply to superbibi

Write a PROC SQL and WHERE using a subquery on the dataset doing a count(*) as count on each scenario, where count >=10

 

 

Ask a Question
Discussion stats
  • 8 replies
  • 314 views
  • 1 like
  • 5 in conversation