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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.