- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Try
%let have =%sysfunc(compbl( 1 2 3));
%let want = %sysfunc(tranwrd(%quote(%trim(&have)),%str( ),%str(,)));
%put want=&want.;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Try
%let have =%sysfunc(compbl( 1 2 3));
%let want = %sysfunc(tranwrd(%quote(%trim(&have)),%str( ),%str(,)));
%put want=&want.;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
These numbers go inside an in statement. if number in (1,2,3). User may also not pass any value to the macro.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have never had to use commas with the IN operator.