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

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
Meteorite | Level 14

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
Meteorite | Level 14

I am sorry,

I run it again and it is working well!

 

thanks

Joe

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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