BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tianerhu
Pyrite | Level 9
libname cert 'C:\practice everyday\input';
libname results 'C:\practice everyday';
data results.output09;
set cert.input09;
a = substr(custID,3,4);
b = a*1000;
custID = tranwrd(custID,a,'9999');
run;
proc print data = results.output09;
run;

when I use variable a instead of 'substr(custID,3,4) as the second argument of the function tranwrd, it doesn't work. why?

The following is the data :

libname cert 'c:\cert\input';
Data cert.input09;
Input custID $;
Datalines;
ID1573
ID2369
ID5361
ID8902
;
Run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

Try defining the A variable first with the proper type and length. You are replacing a character string, length of 4.

 

data results.output09;
length a $ 4;
set cert.input09;
a = substr(custID,3,4);
b = a*1000;
custID = tranwrd(custID,a,'9999');
run;

 

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

View solution in original post

2 REPLIES 2
ChrisHemedinger
Community Manager

Try defining the A variable first with the proper type and length. You are replacing a character string, length of 4.

 

data results.output09;
length a $ 4;
set cert.input09;
a = substr(custID,3,4);
b = a*1000;
custID = tranwrd(custID,a,'9999');
run;

 

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
tianerhu
Pyrite | Level 9

Thank you for your help.

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
  • 2 replies
  • 856 views
  • 0 likes
  • 2 in conversation