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.
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!
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.