When I import file from EXCEL(XLS), if there exists both missing values and numeric values in a same variable, SAS would read them as a mix variable. So is there anyone know how to transfer this type of format to numeric only? Thanks and Regards.
SAS variables are either CHARACTER or NUMERIC in type. If you need to convert from one format to another, assign a new SAS variable and use the INPUT or PUT function in a DATA step. Importing with a DATA step provides you more control over how the input data is interpreted, as compared to PROC IMPORT and the SAS-generated program, based on its data interpretation at import time.
Will the put statement work if you have already imported the file through File>Import? If so, can you give me an example of how to run this? I am having a similar problem when I import an Excel file with alot of missing values, SAS reads the variable as CHAR & i lose the data further down the column.
provided by "DATA _NULL_", this most useful example was the only reference to DBSASTYPE in the discussion Forums, so I wanted to add my experience today :-( - it took some time to appreciate that the column name must be defined in the excel context.
The column name in SAS was SBU_code, but using that caused the error message[pre] ERROR: Invalid column name specified in DBSASTYPE option: SBU_code[/pre]Took me a while to discover that there was no _ in the column name in excel.
The working syntax (abbreviated) [pre]data wrking.sasgla_sbu ;
set model2.'SAS_GLA_SBU'n( dbSAStype=( "SBU code"n='char(5)' ) );
run ; [/pre]