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
%let v1=1806; %let v2=1805; %let v3=1803; %let v4=1712; %let vector=%sysfunc(catx(+,&v1.,&v2.,&v3.,&v4.)); %put &vector.;
@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.
Have you tried writing:
%let vector = 1806+1805+1803+1712;
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.;
%let v1=1806; %let v2=1805; %let v3=1803; %let v4=1712; %let vector=%sysfunc(catx(+,&v1.,&v2.,&v3.,&v4.)); %put &vector.;
"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
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
I am sorry,
I run it again and it is working well!
thanks
Joe
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.
Ready to level-up your skills? Choose your own adventure.