Help using Base SAS procedures

how to get a when statement to work with negative numbers

Accepted Solution Solved
Reply
Regular Contributor
Posts: 240
Accepted Solution

how to get a when statement to work with negative numbers

a HI I have an if statement

data ms;

set ms;

actual = datedif (date,today(), 'act/act');

put actual= ;

gets me number  of days from date to today date...

data ms;

set ms;

select;

when (actual=.) copy= " ";

when (actual <0 or  actual > -15 ) Copy "pre_15";

when ( actual >=1 or actual <=90) copy " post_90";

end;

run;

I Want to Id what's within 15 days an that number is  a negative reason its a -15...

i Want to ID post 90 days I'm using today date to get the datediff and date. Thanks

Message was edited by: gilbert arredondo


Accepted Solutions
Solution
‎08-17-2015 11:26 PM
Super User
Posts: 19,822

Re: how to get if statement to work with negative numbers

You need AND not OR In your conditions.

As Chris has indicated you need an equal in your assignment statement for the copy variable.

View solution in original post


All Replies
PROC Star
Posts: 1,760

Re: how to get if statement to work with negative numbers

1- There is no IF in your code; what with the title?

2- The copy keyword is invalid syntax as used in your code

3- The last sentences make little sense

If you want to be helped the least you can do is present a properly explained and presented case.

Regular Contributor
Posts: 240

Re: how to get if statement to work with negative numbers

it was an if statement I change it before I asked the question....Chris if it doesn't make sense  to you need to respond I try to make it as clear as possible

Solution
‎08-17-2015 11:26 PM
Super User
Posts: 19,822

Re: how to get if statement to work with negative numbers

You need AND not OR In your conditions.

As Chris has indicated you need an equal in your assignment statement for the copy variable.

Regular Contributor
Posts: 240

Re: how to get if statement to work with negative numbers

Thanks Reeza ... I will take your suggestion...It a snippe of code that works for me on other code but it's character not number 

Regular Contributor
Posts: 240

Re: how to get if statement to work with negative numbers

HI reeza 

i Got it

data table;

set table;

if actual ge 0 and actual Le 90 then copy = "post_90";

thanks

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 428 views
  • 0 likes
  • 3 in conversation