PROC IMPORT in SAS: format issue
Salah
-
Véronique -
Véronique -
Hello,
How can I force SAS to keep the same variable format from Excel when using a PROC IMPORT?
In my Excel file, the ID variable is alphanumeric, but SAS considers it a numeric variable and then puts a dot for values containing a letter.??
PS. I am using version 8 of SAS (so I can't use the mixed=yes option).
Thank you for your help.
How can I force SAS to keep the same variable format from Excel when using a PROC IMPORT?
In my Excel file, the ID variable is alphanumeric, but SAS considers it a numeric variable and then puts a dot for values containing a letter.??
PS. I am using version 8 of SAS (so I can't use the mixed=yes option).
Thank you for your help.
3 answers
-
There is the option mixed=yes which allows for the complete conversion to character.
There is also the option guessingrows = 50 to specify the number of rows to scan to identify the type of the variable. -
I think we first need to create an empty dataset with the variables and their defined format (data x; length var1 $10....). Then, we import the data using the proc import in this dataset.
I hope it will work. -
The PROC IMPORT assigns a format based on the first 8 rows. If these rows are predominantly numeric (or empty), then it will be numeric; if they are predominantly text, then it will be text.