Dear all,
I try to keep only the first 11 character from string with carriage return.
ex:
"In progress. # 1 DCF[ CLOSED ] 02/03/2017 15:46Mr A. ADJE wrote null.and proposed value 999,999,999. 30/06/2017 11:10Mme
M. CANEAU wrote ok.and proposed value null. # 1 Notification. Change performed by Mme M. CANEAU on 30/06/2017 11:10 :ok-new
value: null"
Please find my sentence in my macro:
%let fileDel2=%unquote(%sysfunc(getvarc(&tabid2,%sysfunc(varnum(&tabid2,&nomvar2)))));
%put &fileDel2;
%let nou=%substr(&fileDel2,1,11);
%put &nou;
The log displays:
In progress. # 1 DCF[ CLOSED ] 02/03/2017 15:46Mr A. ADJE wrote null.and proposed value 999,999,999. 30/06/2017 11:10Mme
M. CANEAU wrote ok.and proposed value null. # 1 Notification. Change performed by Mme M. CANEAU on 30/06/2017 11:10 : ok - new
value: null
ERROR: Macro function %SUBSTR has too many arguments.
ERROR: The macro KEEPMONITORTAB will stop executing.
If i perform directly on table without macro, it works.
What can I do for that works also throught macro?
Thanks for your help
You can probably (can't get it right now) get away with this:
%let nou = %unquote( %substr(%superq(fileDel2), 1, 11) ) ;
Most likely, the problems occur because of the commas within the value of &fileDel2. %SUBSTR interprets them as marking the end of one parameter and the beginning of the next.
Simple answer: don't do it. Macro language is for the creation of dynamic code, not for manipulating data.
An abomination like
%let fileDel2=%unquote(%sysfunc(getvarc(&tabid2,%sysfunc(varnum(&tabid2,&nomvar2)))));
is the consequence of trying to abuse the macro processor.
You can probably (can't get it right now) get away with this:
%let nou = %unquote( %substr(%superq(fileDel2), 1, 11) ) ;
Most likely, the problems occur because of the commas within the value of &fileDel2. %SUBSTR interprets them as marking the end of one parameter and the beginning of the next.
Thank you that works
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.