I imported an excel datasheet using proc import and one of the date columns came in as a character variable with numbers populated. Is there anyway to modify the proc import so that the date data comes in as it should? MM/DD/YYYY? I know this is happening because some values are stored as year only and some are blank.
A variable only has one type, unlike a spreadsheet in a dataset you cannot mix numbers and character strings. If the column has some cells with dates (numbers) and some with strings then SAS will be forced to create the variable as character. When it does that the values of cells that contain date values are stored as the string of digits that represent the number Excel stores for that date. So the date 01JAN2021 will show up as the string '44197' instead of either '01JAN2021' or the number 22,281 that SAS would use to represent that date.
The best solution is to fix the column in the spreadsheet so that every value is a string. Then what you have in SAS will be the string.
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.
Explore Now →SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.