Can you exclude a row in a dataset in SAS? I know you can do it in JMP but can't find anything about it in SAS.
If the only option is to delete, how do I delete a row with specific variables? For example, the two rows I want to delete have the following categorical variables. This combination of variables makes those rows unique.
Row 1: Loc = A, Hyb=X03, Ntrt = High, Density = Low
Row 2: Loc = B, Hyb = X04, Ntrt = Low, Density = Low
Thanks
Something like this:
Data want ;
set have ;
if loc="A" and Hyb="X03" and Ntrt="High" and Density="Low" then delete ;
if loc="B" and Hyb="X04" and Ntrt="High" and Density="Low" then delete ;
run;
Something like this:
Data want ;
set have ;
if loc="A" and Hyb="X03" and Ntrt="High" and Density="Low" then delete ;
if loc="B" and Hyb="X04" and Ntrt="High" and Density="Low" then delete ;
run;
proc sql;
delete from my_dataset
where (Loc = 'A' and Hyb = 'X03' and Ntrt = 'High' and Density = 'Low')
or (Loc = 'B' and Hyb = 'X04' and Ntrt = 'Low' and Density = 'Low');
quit;
Or, if you just want to exclude those rows:
proc sql;
create table want as
select *
from my_dataset
where not (Loc = 'A' and Hyb = 'X03' and Ntrt = 'High' and Density = 'Low')
and not (Loc = 'B' and Hyb = 'X04' and Ntrt = 'Low' and Density = 'Low');
quit;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.