08-18-2016 02:47 PM
Hi again helpful SAS community!
A couple of weeks ago, Reeza was super helpful and helped me create run a macro by pulling ids from a large (10,000) file.
Here's what she suggested - which worked
Data _null_; Set idlist2; Str = catt('%tool(', id, ');'); Call execute ( Str); Run;
However, part of my Macro involved running an x-command, and although I was indeed generating multiple excel spreadsheets, the data within the docs generated were messed up ... I *think* because of timing issues.
In any case, what I need now is to parse TWO fields from the IdList dataset into my Macro ... here's what I'm trying (code below), but it doesn't work.
Data _null_; Set idList; Str = catt('%tool1(', id, Id2, ');'); Call execute ( Str); Run;
I think I'm missing something really basic about the "CATT" function that I just can't see. I hope this is a really basic error - I don't mind looking dumb if I can learn something new! I hope someone can help me figure this out.
thank you so much!
08-18-2016 03:38 PM
Perhaps try to put the contents of STR prior to the call execute. And why are you sure that this has to do with the catt function? You need to debug all steps, including the macro.
A LOG would help...
I can't see the macro definition here, but but you may want a comma between id and id2?
08-18-2016 04:57 PM
Thanks Linus .. I did debug and test the Macro independently; my other responses here should help clarify why I think it's the CATT function.
Thanks for helping ...and I love your tag line!
08-18-2016 03:39 PM
The string being passed to Call Execute needs to be a valid SAS syntax. Currently it's not.
One way to debug this is to create a dataset and examine the values of STR being created.
Data check; Set idList; Str = catt('%tool1(', id, Id2, ');'); *Call execute ( Str); Run;
Open the check dataset and examine the values of STR. If they'renot valid SAS code, what does it need.
08-18-2016 04:16 PM
Thanks everyone. I did use SYMBOLGEN option so I could see how the macro was resolving.
Yeah, I agree, there's a comma missing ... however, when I tried to add one - here's the code & error message:
952 Str = catt('%tool1(', id,"," Id2, ');'); --- 22 ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, ',', -, /, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.
The reason I think I'm just not getting some nuance of CATT is that if I use the old method of concatenating (I'm a dinosaur):
Str2 = '%tool1(' || trim(id) || ',' || trim(IdN) || ');' ;
I get what I need. I should be content LOL .. but it's bugging me that CATT won't work here.
08-18-2016 05:00 PM
LOL!! That's it!! <DUH!>
Sigh ... reminds me of when I first started using SAS 20 years ago and would forget a semi-colon!
I've been away from SAS for 2 years ... one gets rusty, but it's nice to know this dinosaur can still learn some new tricks!
thanks again Reeza, and everyone else here to helped!
Love the SAS community!
08-18-2016 03:50 PM
Could provide at least an example of the input values and what the catt function is yielding?
Since you have a variable from your data set that we have no idea about the value it is kind of hard to guess.
if that ID variable contains punction such as , or % or & then lots of potential issues.
08-18-2016 04:45 PM
Hi Ballardw ... here's a sample of the IDlist .. nothing that should be a problem
ID ID2 T1-OX3-3007 S3007 T1-OX3-3010 S3010 T1-OX3-3081 S3081 T1-OX3-3083 S3083 T1-OX3-3087 S3087
thanks for helping
Need further help from the community? Please ask a new question.