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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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