Hi,
I have a simple problem I want to solve. I have a column where the output is, ex. 1303/0000/1. But I only need '1303' that I'll eventually convert into a currency value later.
Current output
Desired output
STATUS_CD | SALES_NPV |
S04 | 1302 |
S04 | 1485 |
S04 | 0967 |
For this they have invented the SUBSTR function:
SALES_NPV = SUBSTR(SALES_NPV, 1, 4);
This function is very basic. I would recommend you have a look at the other SAS functions as well.
Regards,
- Jan.
Since you have the / as a delimiter you can also use the SCAN() function.
I can name that tune with 0 functions:
data want;
length sales_npv $ 4;
set have;
run;
There's only room to save the first four characters, once the length has been defined.
Thanks everyone! I was almost too embarassed to ask.
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.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.