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;
The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
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: 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!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 748 views
  • 3 likes
  • 6 in conversation