Hi,
I have a datset which has 5digit numbers that ends with 2 or 4. I want to delete the entire row if the last digit is 4.
example:
ID Sample
1 00012
2 00034
3 00032
4 00124
5 00432
I want to delete the row which has the last digit 4. In the above example, I want to delete 00034 and 00124.
Can I do this in SAS to remove if the 5th digit is 4.
thanks in advance.
If Sample is character then this should do it:
data Want; set Have; if substr(Sample,5,1) = '4' then delete; run;
Or like this :
data have; input ID Sample $; cards; 1 00012 2 00034 3 00032 4 00124 5 00432 ; run; data want; set have; where reverse(strip(Sample)) NOT =: '4'; run; /* end of program */
Koen
If the variable in numeric, you would use the MOD function
if mod(sample,10)=4 then delete;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Latest Updates
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.