Team,
I have this and it works fine:
%let have = 1 2 3;
%let want = %sysfunc(tranwrd(%quote(%trim(&have)),%str( ),%str(,)));
%put want=&want.;
But if the user put more than one space between the numbers then it comes up as 1,2,,,3.
The above code will not work for:
%let have = 1 2 3;
%let want = %sysfunc(tranwrd(%quote(%trim(&have)),%str( ),%str(,)));
%put want=&want.;
Please advise.
Thanks
Try
%let have =%sysfunc(compbl( 1 2 3));
%let want = %sysfunc(tranwrd(%quote(%trim(&have)),%str( ),%str(,)));
%put want=&want.;
Try
%let have =%sysfunc(compbl( 1 2 3));
%let want = %sysfunc(tranwrd(%quote(%trim(&have)),%str( ),%str(,)));
%put want=&want.;
These numbers go inside an in statement. if number in (1,2,3). User may also not pass any value to the macro.
@david27 wrote:
These numbers go inside an in statement. if number in (1,2,3). User may also not pass any value to the macro.
The SAS IN operator does not require commas any more though it used to.
Also for INTEGER values a SAS IN comparison can use a range indicated with a colon: Number in (1:3); is the same as Number in (1 2 3) or Number in (1,2,3).
Thank You team for the responses.
I just learnt about the in operator not requiring comma(,) within parenthesis ACCIDENTALLY just today(because of a programming mistake i did).
By the way---From when did it change?
I have never had to use commas with the IN operator.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.