Date change from YYYYMMDD to MM/DD/YYYY
Posted: 02 March 2013 10:43 AM   [ Ignore ]
Total Posts:  10
Joined  2012-03-03


I am stuck at this problem. Is there any code to convert from YYYYMMDD to MM/DD/YYYY? Thank you so much.

Posted: 03 March 2013 09:09 AM   [ Ignore ]   [ # 1 ]
Total Posts:  901
Joined  2011-09-19

hi SamLe,

Is the variable stored as a character variable, or a date variable. You can tell by double-clicking in the column name (or rightclick on the dataset in the explorer and select ‘view columns’.

If the variable is a character (type text), you would need to manipulate the string. Take the substring of positions 1-4 (the year), 5-6 (month) and 7-8 (day) and create a date variable with function mdy.

If the variable is a date, things are easier. A date is stored as a number in memory, and can be displayed using different formats. In that case, you add a ‘format’ statement in a datastep (no other calculations/transformations are needed).

See here for examples:

best regards,



To reply/post new questions: Please use the group WRDS/SAS on Google Groups!