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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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