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: 6,500

Re: Convert SAS Date Variable to Numeric Variable


All Replies
Super User
Posts: 5,256

Re: Convert SAS Date Variable to Numeric Variable

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: 6,500

Re: Convert SAS Date Variable to Numeric Variable

Frequent Contributor
Posts: 101

Re: Convert SAS Date Variable to Numeric Variable

Thank you so much @tom!!

John

☑ This topic is SOLVED.

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

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