Hello
Let's say that in vector parameter we have 5 arguments:
current month+previous month+last DEC+same month previous year+last month previous quarter
Sometimes some arguments are same.
for example:
current month=1807
previous month=1806
last DEC=1712
same month previous year=1707
last month previous quarter=1806
vector=1807+1806+1712+1707+1806;
How can I tell sas that in case that there are identical arguments in &vector parameter to leave only one of them.
so I want that vector=1807+1806+1712+1707;;
Store data in a dataset, then use Base SAS datasteps and procedures to manipulate data. This is the fundamental of SAS programming.
Thank you.
You are telling me to store the information in data set and then take distinct values.
But ,I get the data in parameter as I showed so we need to search for solution from here.
There is no data set.
How can I create a data set from information in parameter?
Read it into a data set. Then manipulate it.
data quarters (keep=quarter);
length quarter $4;
do i = 1 to countw("¶m","+");
quarter = scan("¶m",i,"+");
output;
end;
run;
and you got a nice dataset from which to work.
So now from the &vector parameter I created a data set.
Then I took the distinct values.
Now I need to create again a parameter with multiple values with + between them
I should I do the final step please?
%let vector=1807+1806+1712+1806;
data tbl1 (keep=YYMM);
length YYMM $4;
do i = 1 to countw("&vector","+");
YYMM = scan("&vector",i,"+");
output;
end;
run;
PROC SQL;
create table tbl2 as
select distinct YYMM
from tbl1
;
QUIT;
/*Now I want to create a parameter called &vector2 that will get the values in table tbl2 with + symbol between values*/
The question is: what will you be doing with that "vector"? There is a fair chance that you can do that directly off the dataset.
If you kept your data in a small dataset (which is the sensible thing to do) instead of a macro variable (which is usually not the smartest thing to do - I'm being polite here!), you'd only need a sort nodupkey or a select distinct.
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!
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.