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?
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);
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?
You can execute the above code in SAS studio and see if you are getting desired result.
Based on your data what would you expect as your output?
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.
You have shown us the source table. Now show us explicitly what the result table would look like.
Hi, I hope the table output shown as the attached, keeping only values depending on "studyeye". Many thanks.
Write a PROC SQL and WHERE using a subquery on the dataset doing a count(*) as count on each scenario, where count >=10
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.