BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
m1986MM
Obsidian | Level 7

Hello everyone,

There is a date variable, containing different dates from 2000 to 2015, in my dataset. I need to group the observation by week. So I wrote the following code to generate the weekly values:

data new; set old;

weekly_date=put(date,weekv5.); run;

The reason for using weekv5. is that I need to know the year and the week of each date.

The problem is that the outcome of the above code is in character format, but I need to compare the weekly_date, for example keep the observation with weekly_date greater than specific time. To do that, I think I need weekly_date should be in numeric format. How can I fix it?

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Don't create a new variable, keeping it in a date form allows you use date functions further on.

format date weekv5.;

View solution in original post

2 REPLIES 2
Reeza
Super User

Don't create a new variable, keeping it in a date form allows you use date functions further on.

format date weekv5.;

m1986MM
Obsidian | Level 7

Thank you.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 855 views
  • 0 likes
  • 2 in conversation