BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello ,

Could you please suggest me the syntax for the " WHERE ne " if I need to remove more than two varaibles.

The code :-

where Review ne 50 ,Review ne 40 AND
Review ne 5;

for example doenot work.The problem is how do i remove three observations with different ranges.

kind regards,
markc
4 REPLIES 4
Cynthia_sas
SAS Super FREQ
Hi:
The documentation on the construction of the WHERE statement is very good:
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000202951.htm

Just as you can have:
[pre]
where age in (11, 12, 13);
[/pre]

You can also use the NOT operator to exclude those particular values for AGE.
As described here in the section on the use of Operators in Expressions:
http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a000780367.htm

cynthia
deleted_user
Not applicable
Hello ,

Could you please tell me as when I remove the observations and then want to permanently replace my original .sas datafile with these changes then what I need to do. I use the following two codes :-

/*Running regression without the observation 2 included*/
proc reg data="C:\Sas\mydata";
model Y=A B C D;
where E NOTIN(16,39)
;
run;
quit;

and

/*predicting Score from A,B,C& D*/
proc reg data="C:\Sas\mydata";
model Y=A B C D ;
output out=mydata1res (keep= Y A B C D)
residual=r predicted=fv;
run;
quit;

What do I need to change in order that observations get removed from the .sas datafile "mydata" as i dont have any dataset defined here.

Kind Regards,
markc
Cynthia_sas
SAS Super FREQ
When you use the reference:
[pre]
... data='c:\SAS\mydata';
[/pre]

It would be the same as if you had coded:
[pre]
... data='c:\SAS\mydata.sas7bdat';
[/pre]
(the file type of .sas7bdat is provided by SAS)

This ability to directly address SAS datasets by their "operating system name" instead of the 2-level SAS name is a feature that will not work on all operating systems.

A method of referencing SAS datasets that will work on all operating systems is to use a LIBNAME statement that points to an operating system storage location and then to use a 2-level dataset to create or reference a SAS dataset in that location.
[pre]
libname perm 'c:\sas';

...data=perm.mydata;
[/pre]

As previously explained, understanding how the LIBNAME statment works is fundamental to understanding how to successfully write SAS programs. A 1-level name creates a dataset in or reads a dataset from the WORK library however, a 2-level name creates a dataset in or reads a dataset from a permanent SAS data library (the physical location specified in the LIBNAME statement).

A .SAS file is an ASCII text file of SAS programming statements. A .SAS file -might- contain a DATALINES section to create a SAS dataset -- but a .SAS program code file is not the same as a proprietary SAS dataset. A .SAS7BDAT file is a SAS dataset that contains data stored in a proprietary format for SAS datasets.

All of the references from previous postings still apply. In order to create a permanent SAS dataset you must several possible techniques. For example, all 3 of these program steps achieve the same results -- I want to create a permanent output dataset (in C:\courses directory) with only Female students from SASHELP.CLASS:
[pre]
libname perm 'c:\courses';

data perm.females;
set sashelp.class;
if sex = 'F' then output;
run;

proc sort data=sashelp.class out=perm.females2;
by sex;
where sex = 'F';
run;

proc sql;
create table perm.females3 as
select *
from sashelp.class
where sex = 'F';
quit;
[/pre]

Each of those steps create a dataset that contains only the observations for female students from SASHELP.CLASS. The next time I need to run an analysis, if I only want to use the observations for the female students, then I could use PERM.FEMALES, PERM.FEMALES2 or PERM.FEMALES3. However, if I wanted to run an analysis for males and females, then I would use the original file, SASHELP.CLASS.

I sincerely suggest that you read the documentation previously posted on the fundamentals of working with SAS datasets. It will be very hard for you to continue to work with SAS programs and SAS datasets if you do not understand the fundamentals of working with SAS datasets.

cynthia
Paige
Quartz | Level 8
> Could you please suggest me the syntax for the "
> WHERE ne " if I need to remove more than two
> varaibles.

Mark

Where does not remove variables (or varaibles).

Where removes observations

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 ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

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