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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 7 replies
  • 3295 views
  • 0 likes
  • 4 in conversation