Hello everyone!
Could somebody advise how i can return format type in SQL query?
I import Excel file and one of column can be imported wirh numeric or char type, and depends on data type i'd like to use code like this:
case when GRB(column name) = numeric then ...
when GRB(column name) =char then...
you can get variable information from SASHELP.VCOLUMN or dictionary table.
data class;
set sashelp.vcolumn;
where libname='SASHELP' and memname='CLASS';
keep name type;
run;
PROC SQL;
SELECT type, name
FROM dictionary.columns
WHERE libname='SASHELP' and memname='CLASS';
QUIT;
If this means that you have been importing multiple files that should have the same structure then you need to take control of how you read data at the beginning. A "column" should have the same properties. Unfortunately Excel enforces no rules on any cell, much less entire columns.
Search the forum for IMPORT and EXCEL. This is such a common problem we answer some form of it nearly daily, if not multiple times per day.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: