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

Hi All,

 

Please kindly help me with the below query.

 

I am trying to create an account number using 2 different variables.

 

I have the following data:

Branch          Account

1000              10090

 

I want the output to look like this:

Account number

100001009000

 

Please kindly assist me.

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@MagD wrote:

Hi All,

 

Please kindly help me with the below query.

 

I am trying to create an account number using 2 different variables.

 

I have the following data:

Branch          Account

1000              10090

 

I want the output to look like this:

Account number

100001009000


accountnumber = cats(branch,'0',account,'00');

 

--
Paige Miller

View solution in original post

8 REPLIES 8
Jagadishkatam
Amethyst | Level 16

if you want to concatenate you can try the below code

 

data want;
set have;
account_number=cats(branch,account);
run;
Thanks,
Jag
PeterClemmensen
Tourmaline | Level 20

Are these character or numeric variables?

MagD
Quartz | Level 8
Hi Draycut. The variables are both numeric variables.
PaigeMiller
Diamond | Level 26

@MagD wrote:

Hi All,

 

Please kindly help me with the below query.

 

I am trying to create an account number using 2 different variables.

 

I have the following data:

Branch          Account

1000              10090

 

I want the output to look like this:

Account number

100001009000


accountnumber = cats(branch,'0',account,'00');

 

--
Paige Miller
novinosrin
Tourmaline | Level 20

Sir @PaigeMiller   How did you make that assumption of the length? does that come from general banking experience with some standardization of branch code length and acctno lengths?

PaigeMiller
Diamond | Level 26

@novinosrin wrote:

Sir @PaigeMiller   How did you make that assumption of the length? does that come from general banking experience with some standardization of branch code length and acctno lengths?


The original problem was stated as:

I want the output to look like this:

Account number

100001009000

--
Paige Miller
MagD
Quartz | Level 8

Thanks, @PaigeMiller PaigeMiller it works!

ballardw
Super User

is Branch always exactly 4 digits? If not what would the desired result be for a 1, 2, 3 or 5 digit branch?

Is Account always exactly 5 digits? If not describe what the result should be for a 1 to 7 digit account.

 

You likely would need to do something to adjust the concatenation for different lengths.

 

Question: Why were these numeric values? Did you import or read a file that stripped leading zeroes from values like 010090

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 8 replies
  • 771 views
  • 0 likes
  • 6 in conversation