BookmarkSubscribeRSS Feed
Dhana18
Obsidian | Level 7

hello, i have data set like this

DATETXTRMT1TRMT2
1/3/201900
1/7/201900
01/22/201910
02/15/201901

 i would like to remove observation that has date but both trmt1 and trmt2 have 0 value.

i used this code:

data janfebs.JAN2FEB2019_MERGED_T_1;
set janfebs.JAN2FEB2019_MERGED_T;
if datetx NE . and TRMT1 and TRMT2="00" then delete;
run;

but it did not work. the log says 


NOTE: Character values have been converted to numeric values at the places given by:
(Line):(Column).
436:20
NOTE: There were 702 observations read from the data set JANFEBS.JAN2FEB2019_MERGED_T.
NOTE: The data set JANFEBS.JAN2FEB2019_MERGED_T_1 has 691 observations and 256 variables.
NOTE: DATA statement used (Total process time):
real time 0.11 seconds
cpu time 0.01 seconds

i originally had 702 observations.

and the result shows same as before observation with 0 values are not removed.

DATETXTRMT1TRMT2
1/3/201900
1/7/201900
01/22/201910
02/15/201901

please help.

2 REPLIES 2
novinosrin
Tourmaline | Level 20

" i would like to remove observation that has date but both trmt1 and trmt2 have 0 value."

 

 

data want;

set have;

if sum(trmt1,trmt2)>0;

run;

 

To include Datetx in your condition

if datetx >. and sum(trmt1,trmt2)>0;
Shmuel
Garnet | Level 18

The condition and TRMT1 and TRMT2="00" means: ... and TRMT1=1 and TRMT2="00" 

which I believe you didn't mean to.

You want to remove observation that has date but both trmt1 and trmt2 have 0 value,

so the correct code is:

if datetx NE . and TRMT1=0  and TRMT2=0 then delete;

Pay attention to the note in the log:

NOTE: Character values have been converted to numeric values 

you did not post the whole log. I suppose the the "00" were converted to 0, assuming TRMT1 and TRMT2, both are numeric.

 

 

    

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 816 views
  • 0 likes
  • 3 in conversation