data lemon; input accountno1 accountno2 accountno3 ; datalines; 1234567890 123456789012 12345678901234 run; data test; set lemon; result1=compress(substr(accountno1,1,8)||put((input(substr(accountno1,9,1),1.)-1),5.)||substr(accountno1,10,7)||put((input(substr(accountno1,17,1),1.)+1),5.)||substr(accountno1,18,2)," "); result2=compress(substr(accountno2,1,8)||put((input(substr(accountno1,9,1),1.)-1),5.)||substr(accountno1,10,7)||put((input(substr(accountno1,17,1),1.)+1),5.)||substr(accountno1,18,2)," "); result3=compress(substr(accountno3,1,8)||put((input(substr(accountno1,9,1),1.)-1),5.)||substr(accountno1,10,7)||put((input(substr(accountno1,17,1),1.)+1),5.)||substr(accountno1,18,2)," "); output out=test; run; proc print data=test; run;
The out= is not required for the output statement in the data step.
output test;
Again, if your question has been answered, please mark the answer as "Accepted Solution" for the benefit of later viewers.
Please review the following guidelines.
https://communities.sas.com/t5/Getting-Started/Community-etiquette-The-do-s-and-don-ts-of-the-SAS-Su...
I get curious about who/why/how someone managed to screw up values in the middle of an account number that need to be adjusted that way.
Post your log in a text box. You will see that the error:
1 data junk;
2 set sashelp.class;
3 output out=junk;
-
79
---
455
ERROR 79-322: Expecting a RC.
ERROR 455-185: Data set was not specified on the DATA statement.
4 run;
The first single underscore associated with the 79-322 error says the = sign is not expected.12 data test;
13 set lemon;
14 result1=compress(substr(accountno1,1,8)||put((input(substr(accountno1,9,1),1.)-1),5.)||substr
14 ! (accountno1,10,7)||put((input(substr(accountno1,17,1),1.)+1),5.)||substr(accountno1,18,2),"
14 ! ");
15 result2=compress(substr(accountno2,1,8)||put((input(substr(accountno1,9,1),1.)-1),5.)||substr
15 ! (accountno1,10,7)||put((input(substr(accountno1,17,1),1.)+1),5.)||substr(accountno1,18,2),"
15 ! ");
16 result3=compress(substr(accountno3,1,8)||put((input(substr(accountno1,9,1),1.)-1),5.)||substr
16 ! (accountno1,10,7)||put((input(substr(accountno1,17,1),1.)+1),5.)||substr(accountno1,18,2),"
16 ! ");
17 run;
NOTE: Numeric values have been converted to character values at the places given by:
(Line):(Column).
14:25 14:60 14:95 14:131 14:167 15:25 15:60 15:95 15:131 15:167
16:25 16:60 16:95 16:131 16:167
NOTE: Invalid third argument to function SUBSTR at line 14 column 88.
NOTE: Invalid second argument to function SUBSTR at line 14 column 124.
NOTE: Invalid second argument to function SUBSTR at line 14 column 160.
NOTE: Invalid third argument to function SUBSTR at line 15 column 88.
NOTE: Invalid second argument to function SUBSTR at line 15 column 124.
NOTE: Invalid second argument to function SUBSTR at line 15 column 160.
NOTE: Invalid third argument to function SUBSTR at line 16 column 88.
NOTE: Invalid second argument to function SUBSTR at line 16 column 124.
NOTE: Invalid second argument to function SUBSTR at line 16 column 160.
accountno1=1234567890 accountno2=123456789012 accountno3=1.2345679E13 result1=1234566890.
result2=123456786890. result3=1.2345676890. _ERROR_=1 _N_=1
NOTE: Missing values were generated as a result of performing an operation on missing values.
Each place is given by: (Number of times) at (Line):(Column).
1 at 14:151 1 at 15:151 1 at 16:151
The way you read the account variables was a numeric values. So when you drop them into a character function, such as SUBSTR, SAS does a conversion to character from number and may not use the character string you expect. There are also some possible side effects from using the || operator to concatenate things that often result in embedded blanks where you don't expect them.
ALWAYS post your log in a code box, like you did with your code. ALWAYS.
I fixed the error and it runs but still I cannot understand what it is trying to do with all the compress input put, also the 5. does not seem to be doing anything significant here
I end up getting all three results with 10 digits
We don't understand either. Using the character function SUBSTR on numeric values is simply a VERY BAD IDEA.
Are you sure that the variable is numeric in your original dataset (use PROC CONTENTS)?
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!
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.