Desktop productivity for business analysts and programmers

IFC Function

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

IFC Function

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


Accepted Solutions
Solution
‎02-21-2013 03:19 PM
Respected Advisor
Posts: 3,156

Re: IFC Function

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


All Replies
Solution
‎02-21-2013 03:19 PM
Respected Advisor
Posts: 3,156

Re: IFC Function

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

PROC Star
Posts: 7,431

Re: IFC Function

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; 

Occasional Contributor
Posts: 9

Re: IFC Function

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!

PROC Star
Posts: 7,431

Re: IFC Function

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.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 287 views
  • 3 likes
  • 3 in conversation