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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.