04-24-2013 11:27 AM
attached is a sample of my data. when I import into sas, gvkey
variable drop the initial 00 , but I need the content intact. that is
what I expected is a sas dataset with 001001.
gvkey year index
001001 1983 1.005130
001001 1984 1.003507
001001 1985 1.004025
001003 1982 1.017350
please help! thanks!
04-24-2013 01:20 PM
Enterprise Guide can handle that conversion for you, but if you are using PROC IMPORT you will have to post-process the data.
If gvkey is desired to be numeric, you can use PROC DATASETS to apply a format (Z6.) to it.
If gvkey is actually a character string that happens to be all digits, then you will need to use a data step to convert, something like
LENGTH gvkey $6.;
04-25-2013 12:13 PM
I do not have Enterprise Guide.
gvkey is a charater, I formatted as text in excel, but when I use SAS- File-Import data (i.e. menu option), it drops the initial 00 from (001001) to 1001 (outcome), could you show some code that use proc import (or other methods) that will preserve the initial 00?
04-25-2013 01:14 PM
PROC IMPORT scans the Excel records to determine the data type, it does not use the Excel format. If you don't have EGuide, the only way I know how to convert is with the DATA step mentioned earlier.
04-30-2013 08:38 AM
You can use the LIBNAME statement to access Excel files
LIBNAME XXX EXCEL "C:\TEST.XLS";
Then set a length/format before reading from the selected sheet
LENGTH GVKEY $6.;
That way you read it as character.