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

Hello

Based on 4 user defined parameter I want that SAS will create a new parameter .

%let v1=1806;

%let v1=1805;

%let v1=1803;

%let v1=1712;

I want that SAS will create a parameter called vector that will have value  1806+1805+1803+1712

(plus delimiter between values)

If We write %put &vector. we need to  see in log  1806+1805+1803+1712

 

thanks

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26
%let v1=1806;
%let v2=1805;
%let v3=1803;
%let v4=1712;
%let vector=%sysfunc(catx(+,&v1.,&v2.,&v3.,&v4.));
%put &vector.;

View solution in original post

7 REPLIES 7
Kurt_Bremser
Super User

@Ronein wrote:

Hello

Based on 4 user defined parameter I want that SAS will create a new parameter .

%let v1=1806;

%let v1=1805;

%let v1=1803;

%let v1=1712;

I want that SAS will create a parameter called vector that will have value  1806+1805+1803+1712

(plus delimiter between values)

If We write %put &vector. we need to  see in log  1806+1805+1803+1712

 

thanks


Since you always use the same macro variable name, the previous values will be lost, and only 1712 will be stored in v1.

andreas_lds
Jade | Level 19

Have you tried writing:

%let vector = 1806+1805+1803+1712;
Ronein
Onyx | Level 15

Sorry

The input parameters are:

%let v1=1806;

%let v2=1805;

%let v3=1803;

%let v4=1712;

 

Following code is not working

%let v1=1806;
%let v2=1805;
%let v3=1803;
%let v4=1712;
%let vector =&v1.+&v2.+&v3.+&v4.;
%put &vector.;

RW9
Diamond | Level 26 RW9
Diamond | Level 26
%let v1=1806;
%let v2=1805;
%let v3=1803;
%let v4=1712;
%let vector=%sysfunc(catx(+,&v1.,&v2.,&v3.,&v4.));
%put &vector.;
andreas_lds
Jade | Level 19

"not working" is such an extremely descriptive error message ... you will have to post at least the log and tell us what you expected. I got the following:

 

23         %let v1=1806;
24         %let v2=1805;
25         %let v3=1803;
26         %let v4=1712;
27         %let vector = &v1.+&v2.+&v3.+&v4.;
28         %put &vector.;
1806+1805+1803+1712
gamotte
Rhodochrosite | Level 12

Hello,

 

Please define "not working". I pasted your code in SAS and obtained the following output.

Isn't that the result you want ?

 

1    %let v1=1806;
2    %let v2=1805;
3    %let v3=1803;
4    %let v4=1712;
5    %let vector =&v1.+&v2.+&v3.+&v4.;
6    %put &vector.;
1806+1805+1803+1712
Ronein
Onyx | Level 15

I am sorry,

I run it again and it is working well!

 

thanks

Joe

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1957 views
  • 2 likes
  • 5 in conversation