11-30-2016 02:38 PM
Wanted Variable to be corrected Trap_Coll_Date;
---> 41503 is stored in excel, but it represents 8/17/2016
Some dates are stored as serial numbers, some dates are stored as regular dates
I can convert the serial numbers in excel into dates, but importing it to SAS reveals the original serial number from Excel. How to I fix this ?
11-30-2016 02:40 PM
Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.
Do you mean you are seeing values like 40123 in the spreadsheet that may represent 11/6/2009?
It may be as simple as setting the column to display as a date in Excel using the FORMAT Cells options.
11-30-2016 02:58 PM
Yes it appears like that, I've tried using the format options to convert the serial numbers to dates.
The problem is not all the dates were imputed into Excel as serial numbers. Some values appear as dates when formated options were changed from date to general.
This is the SAS output after importing the excel file
11-30-2016 03:36 PM
I'm not sure you can add the date format in PROC IMPORT.
So just add next code:
proc import ..... /* your code as is */
proc datasets lib=grad nolist;
format date date9.; /* or any other SAS date format */
11-30-2016 03:57 PM
I used the code you sent me, and sas Log stated this:
1320 proc datasets lib=grad nolist;
1321 modify mosdata;
ERROR: You are trying to use the numeric format DATE with the character variable trap_coll_date in
data set GRAD.MOSDATA.
1322 format Trap_Coll_Date date9.; /* or any other SAS date format */
is this because sas is reading dates as a character variabel instead of a numberic variable ?