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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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