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