I’m trying to delete certain data with variables not equal to one, but the below code deletes all the data. I can’t figure out the OR statement so that not all the data is deleted. I’m running a relative risk analysis and have included that code for reference
ata hf8mb;
set hf8;
time = 0 ;
if timelapse < .8 then delete;
if surver = 'BIT1' then delete;
if met_brst_scrn ne 1 then delete;
if met_cer_scrn ne 1 then delete;
if met_cer_scrn ne 1 then delete;
if met_co_scrn ne 1 then delete;
if met_pneu_vac ne 1 then delete;
if met_hpv_vac ne 1 then delete;
if met_flu_vac ne 1 then delete;
keep time par_id....
proc freq data=hf8m3 order=data;
tables time*need_brst_scrn / relrisk;
run;
Use a single condition (because the action is always DELETE).
If you intend for all conditions to be true to cause a delete, combine them with AND.
BTW OR is not a statement, it is a logical operator.
The SAS DELETE statement removes observations.
Are you intending to set values to missing so they are not included in analysis?
Might be a good idea to show an example of your data and what you expect the result to look like AFTER this process is done.
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: