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-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!

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
  • 6 replies
  • 897 views
  • 0 likes
  • 4 in conversation