BookmarkSubscribeRSS Feed
CharlesR
Calcite | Level 5
Hello, First time here. I have a data set where i would like to remove observations which equal a particular value of a variable. Here's what i've got:

data st.Def_2008;
delete all where (ResultType=77);
run;

Here's the error i get:
ERROR 79-322: Expecting a ;.

ERROR 76-322: Syntax error, statement will be ignored.

Help?
10 REPLIES 10
andreas_lds
Jade | Level 19
You should read the "SAS 9.2 Language Reference: Concepts, Second Edition", especially the chapter about "DATA step concepts".

Link: http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#/documentation/cdl/e...
Ksharp
Super User
> data st.Def_2008;
> delete all where (ResultType=77);

Why not use 'not' operation symbol.

data st.Def_2008;
where ResultType ne 77 ;
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
There definitely needs to be more substance to the DATA step - either a SET (providing an input SAS member) or some type of assignment statements to derive one or more SAS variables and then use an IF THEN DELETE; or some similar-result oriented coding technique.

However, as was suggested, the SAS DOC and other supplemental technical reference material hosted at SAS.COM support website will be quite useful to the original poster.

Scott Barry
SBBWorks, Inc.
Ksharp
Super User
Thanks . Sbb.
There are more things i have to learn.And also forget SasKiwi's right code.:(
FredrikE
Rhodochrosite | Level 12
Try sql instead:

proc sql;
delete *
from st.Def_2008
where ResultType=77
;
quit;
CharlesR
Calcite | Level 5
Thanks so much for all the help everyone! Proc SQL seems like what I'm really looking for! I have multiple situations to eliminate observations and it's what is easiest for me to get a handle on.
SASKiwi
PROC Star
The equivalant DATA step logic is:

data st.Def_2008;
set st.Def_2008;
if ResultType=77 then delete;
run;

The advantage of the DATA step is you can do a lot more in the same step with only one pass of the data than you can in SQL, for example create more than one output dataset containing different results.
FredrikE
Rhodochrosite | Level 12
One advantage with proc sql is that index is kept and that you don't rewrite the table, useful when working with larga ds...
Anilsk
Fluorite | Level 6
Just try this code:

data st.Def_2008; /*Destination dataset */
set st.Def_2008; /*Source dataset*/
if ResultType=77 then delete;

It should delete that particular value from the dataset.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Also consider using a WHERE statement, if appropriate, for efficiency.

Scott Barry
SBBWorks, Inc.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 10 replies
  • 1787 views
  • 0 likes
  • 7 in conversation