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

Data I have:

10/22/2005

01/10/2010

 

Data I want:

October 22, 2005

January 10, 2010

 

If possible, I would the day of the week for each date. Example: 04/04/2019 becomes Thursday, April 4, 2019

1 ACCEPTED SOLUTION

Accepted Solutions
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

Data have;
input date $10.;
cards;
10/22/2005
01/10/2010
;
data want;
set have;
new_date=input(date,anydtdte21.);
weekday=input(date,anydtdte21.);
format weekday DOWNAME. new_date worddate.;
run;

View solution in original post

6 REPLIES 6
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

Data have;
input date $10.;
cards;
10/22/2005
01/10/2010
;
data want;
set have;
new_date=input(date,anydtdte21.);
weekday=input(date,anydtdte21.);
format weekday DOWNAME. new_date worddate.;
run;
novinosrin
Tourmaline | Level 20

Hi @VDD   Good answer, but may i ask why are you using anydt informat as opposed to mmddyy informat. No biggie but just wondering

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

I used that format in the second date step just because it was usable there.  I could have used the mmddyy10. format.

here is a sample where you could have the full request in 1 variable.

 

data want;
set have;
new_date=input(date,anydtdte21.);
weekday=input(date,anydtdte21.);
one_date = input(date,anydtdte21.);
format weekday DOWNAME. new_date worddate. one_date weekdate.;
run;

 

Shivam
Calcite | Level 5

Try this,

 

you'll get weekday and date in same column

 

data want;
set have;
format date WEEKDATX23.;
run;
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

@Shivam did your run the code or just read the code?

Shivam
Calcite | Level 5

Hi,

 

I ran your code, that worked fine. why?

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1145 views
  • 0 likes
  • 4 in conversation