Hi Guys,
I currently have dates which are characters.
196507
196508
196509
.
.
In YYMM, where they have format and informat as $6.
I would like to convert them into SAS dates so that I can work on them easily. I.e. remain as196507, 196508, 196509...... but are in the SAS dates with format and informat YYMMN6.
I tried the following code but it doesn't seem to work:
DATA OUT;
SET IN;
DATENEW= INPUT (DATE, YYMMN6.)
RUN;
196508 becomes 2039
196509 become 2070... ...
Thanks for the help guys!
Can't repeat your issue on SAS 9.3.
data want;
input date $6.;
DATENEW= INPUT (DATE, YYMMN6.);
format datenew date9.;
put "datenew=" datenew;
cards;
196507
196508
196509
;
Haikuo
UPdate: I see what is going on: the number you are seeing is the day count from 1/1/1960, it is how SAS store its date variable, you would need to assign a format to see the conventional date that we are using in everyday life.
Can't repeat your issue on SAS 9.3.
data want;
input date $6.;
DATENEW= INPUT (DATE, YYMMN6.);
format datenew date9.;
put "datenew=" datenew;
cards;
196507
196508
196509
;
Haikuo
UPdate: I see what is going on: the number you are seeing is the day count from 1/1/1960, it is how SAS store its date variable, you would need to assign a format to see the conventional date that we are using in everyday life.
Benn must add the format statement to see the internal date value as he wants.
2039 and 2070 and so on in the number since 01JAN1960. Readin the SAS Online doc in the chapter
About SAS Date, Time, and Datetime Values
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.