I have built some macro code that passes the value in a given row of a field to a macro variable that is then used as part of a string to pull down a CSV file from a website. I've tried setting this field with a default length of $8. in a 'CALL SYMPUT' statement.
This does not work as most (but not all) of the string lengths are 4. When the code is run in the log you can see the trailing spaces in the URL being submitted to the website and the code falling over.
When I've tried it with the 'CALL SYMPUT' length of $4. it works fine on those strings that are four characters long.
This would all be alright except some character strings are one, two, three, five of six characters long. I've tried using the '%TRIM' function in the manner of %let mynewvar =%trim(&myoldvar.);' but it causes the same error where the submitted macro variable in the URL has trailing spaces...
...what am I doing wrong?
Thanks
%trim
seems to work nicely for me in this simple example data null; call symput('FOO','abc '); run; %put XX&FOO.XX; %put XX%trim(&FOO.)XX; ` – John Leveille