BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lillymaginta1
Obsidian | Level 7
data have;
infile cards ;
input ID   $Date1 ;	 
cards;
001 200404
002 201205
003 200903
;
run;

I have a data with date variable entered into a character format. Would it be possible to: 1) assign all dates a day of "01" and 2) convert the variable to SAS date

Output

001 04012004

002 05012012

003 03012009 ;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

Yes, of course, something like

 

data want;
  set have(rename=(Date1 = DateStr));
  Date = input(cats(DateStr, '01'), yymmdd8.);
  format Date mmddyy8.;
run;

View solution in original post

3 REPLIES 3
andreas_lds
Jade | Level 19

Yes, of course, something like

 

data want;
  set have(rename=(Date1 = DateStr));
  Date = input(cats(DateStr, '01'), yymmdd8.);
  format Date mmddyy8.;
run;
lillymaginta1
Obsidian | Level 7

Super! thank you! 

japelin
Rhodochrosite | Level 12
data want;
  set have;
  sasdt=input(cats(date1,'01'),yymmdd8.);
  format sasdt mmddyyn8.;
run;

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
  • 3 replies
  • 356 views
  • 3 likes
  • 3 in conversation