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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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