THIS IS THE SAMPLE CODE
DATA D;
INPUT DATE :BEST12.;
DATALINES;
20020328
19990214
;
RUN;
I WANT TO CONVERT DATE VARIABLE VALUES IN TO DATE9. FORMAT
PLEASE HELP ME OUT
I posted a response to your original thread:
I think that you are looking for something like:
data dunning;
input DT_DUNNING_DATE;
cards;
19980428
20100324
20110330
;
DATA TEMP;
SET DUNNING;
DT_DUNNING_DATE1=
INPUT(put(DT_DUNNING_DATE,8.),yymmdd8.);
FORMAT DT_DUNNING_DATE1 DATE9.;
RUN;
but now the date variable is in best12. format
i am not getting the way to convert it into date9. format.
Now it is a SAS date value with a date9. format. That is what you will need if you want to use it as a date.
Do you not want it to be a SAS date but, rather, the text that only appears to look like a SAS date9. formated value?
ultimately what i want is to convert those values in numbers of days so that i can apply date formats on it.
A SAS date value is simply a number representing the number of days since 01JAN1960. As such, the difference between two SAS dates is the number of days that separate them.
Additionally, as Tom mentioned, you can do a lot more with the various date related functions.
If you are reading the values from datalines or a text file then use the appropriate date format and the value will be stored as the number of days since 1/1/1960. Then you can do differences and other operations on the date. Look at functions that SAS has for date calculations for doing more complex operations with dates.
DATA D;
INPUT DATE yymmdd8.;
format date date9.;
CARDS;
20020328
19990214
RUN;
really thank full for your response
the main problem is that the dataset is alreadly created the date variable with best12. format.
i want to apply mmddyy or date9. format on it.. how can i pls guide me
I apparently don't understand what you are asking. I had thought that what I suggested, before, matched your current situation. I expanded on it, below, to show an example calculation:
data dunning;
input DT_DUNNING_DATE;
cards;
19980428
20100324
20110330
;
DATA TEMP;
SET DUNNING;
DT_DUNNING_DATE1=
INPUT(put(DT_DUNNING_DATE,8.),yymmdd8.);
FORMAT DT_DUNNING_DATE1 DATE9.;
Number_of_Days_from_01JAN2010=
DT_DUNNING_DATE1-'01JAN2010'd;
RUN;
thnx u vry much
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 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.