BookmarkSubscribeRSS Feed
deleted_user
Not applicable
hi all,

if i have a dataset look something like this:

Name NRIC Weight Height
A XX XXX XXXX
B XX XXX XXXX
:
:
F XX XXX XXXX
G XX XXX XXXX

and i want to delete all the observation before Name = 'F', Does anyone knows how should I code it?
3 REPLIES 3
SushilNayak
Obsidian | Level 7
Hi Qiqi,
try making a counter which is set to some value say =0 and as soon as the name='F' is encountered change the value of the counter to say = 1. Use the output statement based on that counter.

data test;
input name:$4. data1:$char10. ;
cards;
A dummy
B dummy
C dummy
D dummy
E dummy
F dummy
G dummy
H dummy
;;;;
run;
data d1(drop=counter);
set test;
retain counter;
if _n_=1 then counter=0;
if name ='F' then counter=1;
if counter=1 or name='F';
run;
proc print;run;
Doc_Duke
Rhodochrosite | Level 12
If you are looking at logical order: in EGuide, you could create an advanced filter with
Name NOT LT "F"
to select the ones to keep.
Patrick
Opal | Level 21
Just to be careful: upcase(name) not lt "F"

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 698 views
  • 0 likes
  • 4 in conversation