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

PROCSQL;

   CREATE TABLE DATA.Claims_with_identifier AS

   SELECT t1.MEMBER,

          t1.ACCT,

          t1.PPRODUCT,

          /* Platform */

            (IFC(Left(t1.ACCT,1)='0','X','Y')) AS Platform

      FROM DATA.Claims t1;

QUIT;

Hello,

I need some helping trying to create an identifier from a SAS data set. I was hoping to use the Left and IFC functions to take a list of Accounts and create labels as appropriate. However, the results of this query show me that all records are labeled as Y. I've checked the data and I know for sure that there are records in the data set that need to be identified as X.

Can someone please let me know if I am missing something?

Thanks,

Srikar

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

Never seen left function being used like that, if what you want to evaluate the first non-blank character, then you can use either substr() or first(),

(IFC(first(Left(t1.ACCT))='0','X','Y')) AS Platform

Haikuo

View solution in original post

4 REPLIES 4
Haikuo
Onyx | Level 15

Never seen left function being used like that, if what you want to evaluate the first non-blank character, then you can use either substr() or first(),

(IFC(first(Left(t1.ACCT))='0','X','Y')) AS Platform

Haikuo

art297
Opal | Level 21

My reply is similar to Haikuo's.  Don't you want something like the following?:

PROC SQL; 

   CREATE TABLE Claims_with_identifier AS  

   SELECT t1.name,  

          t1.age,  

          t1.height,  

          /* Platform */ 

            (IFC(substr(left(t1.name),1,1)='M','X','Y')) AS Platform 

      FROM sashelp.class t1; 

QUIT; 

SrikarA
Calcite | Level 5

Still a newbie to SAS, so I wasn't entirely sure which function to use. I've used LEFT() before in Access and it works well.

Thanks for all your help!

art297
Opal | Level 21

Different function.  Left in access is like substr in SAS, but copies X characters starting from position 1.  Left, in SAS, simply removes space characters from the left side of a field.  You may not need it for your current code and only require the substr function.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 1150 views
  • 3 likes
  • 3 in conversation