BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello,

I have several variables that are in mmddyy8. form in a data set for which I don't care about the years but rather the day of the year. I've converted them to julian day format using:

format datevariable julday8.;

this works, but a following if/then statement like:

if datevariable < 135 then dummy = 1;

doesn't work for some reason.

Of course, the juldate function works in this situation, as in:

if juldate(datevariable) < x then dummy = 1;

but the juldate is much different than the julday. Does anybody know if there is a function for julday (day of year) rather than just for juldate? Also, can anybody see me why my if then statement doesn't work?
4 REPLIES 4
Doc_Duke
Rhodochrosite | Level 12
A partial answer for you. This statement

if datevariable < 135 then dummy = 1;

doesn't work because the native form of a date variable is an integer with day 1 as 1/1/1960.
deleted_user
Not applicable
Okay, i've figured out what I was confused about. Sorry for the silly question....

td
data_null__
Jade | Level 19
> Hello,
>
> I have several variables that are in mmddyy8. form in
> a data set for which I don't care about the years but
> rather the day of the year. I've converted them to
> julian day format using:
>
> format datevariable julday8.;

This doesn't change the value only the way it is displayed.
>
> this works, but a following if/then statement like:
>
> if datevariable < 135 then dummy = 1;
>
> doesn't work for some reason.

Try
[pre]
if input(put(datevariable,julday8),8.) lt 135 then dummy =1;
[/pre]
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
  • 4 replies
  • 1890 views
  • 0 likes
  • 4 in conversation