Hi Expect.
i have the following dataset: VAR
20000000427276985 3020210406999912310000004476Z1000000Z100000100005100DR009500000000010137899589
And when i do a substr it return blank colums.
code:
PROC SQL;
CREATE TABLE MAP_COP_FILE AS
SELECT
SUBSTR (CAT(VAR1),1,1) AS ITEM,
SUBSTR (CAT(VAR1),2,35) AS 'External Account Number'N,
SUBSTR (CAT(VAR1),37,2) AS 'Account Status'N
FROM VBM.SAP_NOM
;
QUIT;
output:
please assist
I get non-blank answers, so something in your code is wrong, or that's not the data.
data have;
var1='20000000427276985 3020210406999912310000004476Z1000000Z100000100005100DR009500000000010137899589';
run;
PROC SQL;
CREATE TABLE outp AS
SELECT
SUBSTR (CAT(VAR1),1,1) AS ITEM,
SUBSTR (CAT(VAR1),2,35) AS acct_no,
SUBSTR (CAT(VAR1),37,2) AS acct_status
FROM have;
QUIT;
Please show us (a portion of) the data, not as something you typed in, but following these instructions.
Also, the CAT function is not needed here.
I get non-blank answers, so something in your code is wrong, or that's not the data.
data have;
var1='20000000427276985 3020210406999912310000004476Z1000000Z100000100005100DR009500000000010137899589';
run;
PROC SQL;
CREATE TABLE outp AS
SELECT
SUBSTR (CAT(VAR1),1,1) AS ITEM,
SUBSTR (CAT(VAR1),2,35) AS acct_no,
SUBSTR (CAT(VAR1),37,2) AS acct_status
FROM have;
QUIT;
Please show us (a portion of) the data, not as something you typed in, but following these instructions.
Also, the CAT function is not needed here.
Why are you calling the CAT function? CAT is intended to combine two or more variables. With a single variable it just adds overhead.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.