BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Akhila1
Fluorite | Level 6

Proc sql;

select * from mytable

where income < 0;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Show the results of Proc Contents on your data set Mytable. If you think you have negative values and none appear than one likely cause is that the variable Income is character and not numeric, second could be a custom format that displays something you think is negative but actually holds a different value.

 

BTW, Proc SQL ends with a Quit statement not Run. Should create output but you may still have proc sql running.

View solution in original post

5 REPLIES 5
Quentin
Super User

The code looks fine.  Please add some sample data to your question which shows this behavior, e.g.:

 

data mytable ;
  income = -1 ;
run ;

proc sql;
  select * from mytable
  where income < 0;
quit;
BASUG is hosting free webinars ! Check out recordings of our past webinars: https://www.basug.org/videos. Save the date for our in person SAS Blowout on Oct 18 in Cambridge, MA. Registration opens in September.
PaigeMiller
Diamond | Level 26

Income < 0, what does that even mean? Somebody who goes to work, the company doesn't pay the worker and the worker has to pay the company money, so his income is negative? Maybe your data set doesn't have any records where Income < 0 because that never happens.

 

If the code you show finds zero records, then there are no incomes less than zero in your data set.

--
Paige Miller
ballardw
Super User

Show the results of Proc Contents on your data set Mytable. If you think you have negative values and none appear than one likely cause is that the variable Income is character and not numeric, second could be a custom format that displays something you think is negative but actually holds a different value.

 

BTW, Proc SQL ends with a Quit statement not Run. Should create output but you may still have proc sql running.

gema
Calcite | Level 5
do a proc univariate to look at your data. univariate gives you the 5 lower and upper extreme values of the variable income. if there are any negative values, they will show up. this is a good way to look at abnormalities for continuous variables

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 5 replies
  • 583 views
  • 3 likes
  • 6 in conversation