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
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
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
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;
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!
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.
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 25. Read more here about why you should contribute and what is in it for you!
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.