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;

 

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.

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;

 

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
tianerhu
Pyrite | Level 9

Thank you for your help.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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