DATA Step, Macro, Functions and more

julian dates; formats and functions

Reply
N/A
Posts: 0

julian dates; formats and functions

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?
Trusted Advisor
Posts: 2,116

Re: julian dates; formats and functions

Posted in reply to deleted_user
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.
N/A
Posts: 0

Re: julian dates; formats and functions

Posted in reply to deleted_user
Okay, i've figured out what I was confused about. Sorry for the silly question....

td
Respected Advisor
Posts: 3,799

Re: julian dates; formats and functions

Posted in reply to deleted_user
> 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]
SAS Employee
Posts: 58

Re: julian dates; formats and functions

Posted in reply to deleted_user
Ask a Question
Discussion stats
  • 4 replies
  • 157 views
  • 0 likes
  • 4 in conversation