Help using Base SAS procedures

Convert SAS Date Variable to Numeric Variable

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 101
Accepted Solution

Convert SAS Date Variable to Numeric Variable

Hello All,

I have a pretty simple question that is really hanging me up.  I am converting some SAS dates using the following code into weekday format (which just returns a number for the day of the week):

data mylib.twt6;

  set mylib.twt1_4;

  wday = nextdt;

  format wday weekday1.;

run;

I am creating a new variable called wday from a full date variable (nextdt) and then converting into weekday format.

But the thing is, I want to be able to do things with that number (the 1-7 number that the weekday format has) such as find the average of the numbers, or sum them.

How can i get those numbers to change to numeric format?

Thanks,

John


Accepted Solutions
Solution
‎11-02-2014 03:19 PM
Super User
Super User
Posts: 7,076

Re: Convert SAS Date Variable to Numeric Variable

Posted in reply to mahler_ji

All Replies
Super User
Posts: 5,438

Re: Convert SAS Date Variable to Numeric Variable

Posted in reply to mahler_ji

Use the corresponding function in the assignment statement.

Data never sleeps
Frequent Contributor
Posts: 101

Re: Convert SAS Date Variable to Numeric Variable

Please forgive me, but I don't know what that means?

Solution
‎11-02-2014 03:19 PM
Super User
Super User
Posts: 7,076

Re: Convert SAS Date Variable to Numeric Variable

Posted in reply to mahler_ji
Frequent Contributor
Posts: 101

Re: Convert SAS Date Variable to Numeric Variable

Thank you so much @tom!!

John

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 367 views
  • 0 likes
  • 3 in conversation