BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Nancy05
Quartz | Level 8

Hi,

 

I have an variable called "SUPPORT_CUST_NAME". It is defined as "Char" type with leng of 100. it is labled as "SupportCustName".

 

Dataset name is "ELT.ELT_SEC_SUPPORT_BY".

 

The problem is that the value of "SUPPORT_CUST_NAME" seems chopped much less than 100. Many names are chopped. I need to find the longest value to confirm my finding?

 

How do I find out the longest length of value for "SUPPORT_CUST_NAME" with its primay key "CR_APPL_NO"?

 

Please help with SAS code!

 

Thanks!

Nancy

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star
proc sql;
  select max(length(SUPPORT_CUST_NAME))
  from ELTElend.ELT_SEC_SUPPORT_BY
  ;
quit;

View solution in original post

7 REPLIES 7
Astounding
PROC Star

Before you examine the lengths, the first step would be to examine the format.  If a variable is defined as $100 but has a format of $50., you will only see the first 50 characters.

Nancy05
Quartz | Level 8

How to write the code to find out?

 

Here is my code to look at the table:

 

data elendSUPPORTBY;
	set ELTElend.ELT_SEC_SUPPORT_BY;


Title "Support by in ELT ELEND";
proc print data= elendSUPPORTBY;
run;

Thanks!

 

SASKiwi
PROC Star
proc sql;
  select max(length(SUPPORT_CUST_NAME))
  from ELTElend.ELT_SEC_SUPPORT_BY
  ;
quit;
Nancy05
Quartz | Level 8

Hi SASKiwi,

 

Thank you so much for the SAS SQL query! The SAS query works very well. 

 

Does the embedded sql query follow standard SQL syntax?  Do they follow Oracle or DB2 or Microsoft standard?

 

Thanks!

Nancy

Reeza
Super User

SAS SQL doesn't necessarily follow ANSI SQL standards. Most basic queries such as the one here, can be used in both Oracle and SQL.  

 

SAS FEDSQL is ANSI standard.

 

Oracle SQL is different than Microsoft SQL.  

 

You can use SQL pass through if you want to pass a query directly to your server.

Astounding
PROC Star

The easiest way to find out formats would be:

 

proc contents data=eltelend.elt_sec_support_by;

run;

Nancy05
Quartz | Level 8

Hi Astounding,

 

Thank you for your suggestion. Yes. I have tried proc contents, that is how I get to know this variable SUPPORT_CUST_NAME is char type with length of 100. But somehow only display 40 chars.

 

It may due to an error in ETL process.

 

Thank you so mcuh for help!

 

Nancy

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 4306 views
  • 0 likes
  • 4 in conversation