Hi,
I need to delete observations that have ns_n ='.' or 0 but leave the rows that have a certain value of drug= 'abc' (which intrinsically has ns_n equal to '.' and 0; they have other values - uns_n and sns_n instead).
When I use this code below all rows containing ns_n ='.' or 0 are deleted including the data with drug 'abc' and I need to keep them:
Data DB_test;
set AB_2020;
if ns_n='.' then delete;
if ns_n =0 then delete;
run;
Thank you.
First of all, one of your statements is wrong and works only because SAS does an automatic type conversion for you. Relying on this is considered bad practice.
Assuming your variable is numeric, do this:
if drug ne 'abc' and ns_n in (0,.) then delete;
First of all, one of your statements is wrong and works only because SAS does an automatic type conversion for you. Relying on this is considered bad practice.
Assuming your variable is numeric, do this:
if drug ne 'abc' and ns_n in (0,.) then delete;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.