BookmarkSubscribeRSS Feed
Maksim_Naumov
Calcite | Level 5

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...

2 REPLIES 2
japelin
Rhodochrosite | Level 12

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;
ballardw
Super User

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.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 539 views
  • 0 likes
  • 3 in conversation