@nmlynar13 wrote:
I have a sas file with 6210 rows with a column "date" formated as mm/dd/yyy (06/30/2002 for example) and I would like to convert it to a string that would read the date as yyyymmdd (20020630 for the date above).
A SAS dataset has variables. What does PROC CONTENTS say about how the DATE variable is defined?
If the variable is numeric with the MMDDYY10. format attached to it then you can just change the format attached to the variable to YYMMDDN8. to have it print the dates in that style.
format date yymmddn8.;
If you want to create a new character variable that has strings that look like then use theYYMMDDN8. format with the PUT() function to generate the new variable.
newvar = put(date,yymmddn8.);
If the variable is character then use the MMDDYY10. informat to convert the values to dates and then use the YYMMDDN8. format to convert it back into a string in that style.
date = put(input(date,mmddyy10.),yymmddn8.);
And if you want to make a new numeric variable that stores dates as number like YY,YYM,MDD then why would you do that?