SAS Procedures

Help using Base SAS procedures
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sasphd
Lapis Lazuli | Level 10

hello 

not= does not work in my program. what is the error? thanks

roc sql;
create table stat_data as
select * from Penality
where
specific_Industry_of_Parent not = 'mortgage lending' or specific_Industry_of_Parent not = "commodity trading; mining" or specific_Industry_of_Parent not= 'banking'
or specific_Industry_of_Parent not = "insurance" or specific_Industry_of_Parent not = "financial services" or specific_Industry_of_Parent not = "banking & securities"
or specific_Industry_of_Parent not = "investment advisory services";

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Use NOT IN instead of NOT =

And SQL requires a QUIT, not RUN.

I'd also recommend using either single or double quote consistently but that's not something I excel at either 🙂

 

Something like this is a lot cleaner IMO:

 

proc sql;
create table stat_data as
select * from Penality
where
specific_Industry_of_Parent not in ( 
'mortgage lending', 
 "commodity trading; mining", 
 'banking',
 "insurance",
 "financial services",
 "banking & securities", 
 "investment advisory services");
quit;

@sasphd wrote:

hello 

not= does not work in my program. what is the error? thanks

roc sql;
create table stat_data as
select * from Penality
where
specific_Industry_of_Parent not = 'mortgage lending' or specific_Industry_of_Parent not = "commodity trading; mining" or specific_Industry_of_Parent not= 'banking'
or specific_Industry_of_Parent not = "insurance" or specific_Industry_of_Parent not = "financial services" or specific_Industry_of_Parent not = "banking & securities"
or specific_Industry_of_Parent not = "investment advisory services";

run;


 

 

View solution in original post

4 REPLIES 4
sasphd
Lapis Lazuli | Level 10

there is no error in the log but the input table did not change

SASKiwi
PROC Star

Change "not =" to "ne". 

Reeza
Super User

Use NOT IN instead of NOT =

And SQL requires a QUIT, not RUN.

I'd also recommend using either single or double quote consistently but that's not something I excel at either 🙂

 

Something like this is a lot cleaner IMO:

 

proc sql;
create table stat_data as
select * from Penality
where
specific_Industry_of_Parent not in ( 
'mortgage lending', 
 "commodity trading; mining", 
 'banking',
 "insurance",
 "financial services",
 "banking & securities", 
 "investment advisory services");
quit;

@sasphd wrote:

hello 

not= does not work in my program. what is the error? thanks

roc sql;
create table stat_data as
select * from Penality
where
specific_Industry_of_Parent not = 'mortgage lending' or specific_Industry_of_Parent not = "commodity trading; mining" or specific_Industry_of_Parent not= 'banking'
or specific_Industry_of_Parent not = "insurance" or specific_Industry_of_Parent not = "financial services" or specific_Industry_of_Parent not = "banking & securities"
or specific_Industry_of_Parent not = "investment advisory services";

run;


 

 

ballardw
Super User

Since this seems to select as expected:

proc sql;
   create table junk as
   select * from sashelp.class
   where sex not = 'F'
   ;
quit;

perhaps the issue is with the spelling of your values. = would be case and space sensitive.

 

Run this and show the result:

proc sql;
   select distinct specific_industry_of_Parent
   from Penality
  ;
quit;

Any chance the data set is actually named "Penalty" and not "Penality"?

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 4438 views
  • 4 likes
  • 4 in conversation