BookmarkSubscribeRSS Feed
yogeswar_123
Calcite | Level 5

data datechar;

input subid char $9.;
cards;
1 04jan2015
2 06feb2019
3 08nov2022
4 undec2016
5 ununk2017
6 15jul2013
run;

3 REPLIES 3
andreas_lds
Jade | Level 19

Please rephrase your question without using abbreviations.

s_lassen
Meteorite | Level 14

I assume you want to correct the input CHAR to a valid date, using averages. Something like this, maybe?

data datechar;
  input subid char $9.;
  if substr(char,1,2)='un' then
    substr(char,1,2)='15';
  if substr(char,3,3)='unk' then 
    substr(char,3,3)='JUL';
  date=input(char,date9.);
  format date date9.;
  drop char;
drop char;
cards;
1 04jan2015
2 06feb2019
3 08nov2022
4 undec2016
5 ununk2017
6 15jul2013
;run;

(apart from adding the calculation of the substrings, I also added a semicolon before the "run;")

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 419 views
  • 4 likes
  • 4 in conversation