BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
VALLY
Fluorite | Level 6

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:

VALLY_0-1626110594316.png

please assist

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
ballardw
Super User

Why are you calling the CAT function? CAT is intended to combine two or more variables. With a single variable it just adds overhead.

Reeza
Super User
Show your log....

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 938 views
  • 0 likes
  • 4 in conversation