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]

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 4 replies
  • 927 views
  • 0 likes
  • 4 in conversation