Hi SAS Users,
I wanted some help with getting the count of pipes '|' of a macro variable.
%LET DLM_COUNT = COUNTC(&PLATFORM,') +1;
&PLATFORM has value like 'ABC|DEF|GHI|QWE'
So i am expecting to 4 in DLM_COUNT.
Thanks,
Ana
Countc is a regulare sas function, not a macro function. So it has to be called via %sysfunc;
Also, you seem to want to count WORDs, where | is the separator:
%let PLATFORM =ABC|DEF|GHI|QWE;
%LET DLM_COUNT = %sysfunc(COUNTW(&PLATFORM,|));
%put &=dlm_count;
Countc is a regulare sas function, not a macro function. So it has to be called via %sysfunc;
Also, you seem to want to count WORDs, where | is the separator:
%let PLATFORM =ABC|DEF|GHI|QWE;
%LET DLM_COUNT = %sysfunc(COUNTW(&PLATFORM,|));
%put &=dlm_count;
Modifying your attempt slightly:
%let dlm_count = %sysfunc(countc(&platform, |));
I can't test it right now, but it looks like it should work.
In retrospect, COUNTW counts the number of words using pipes as delimiters. COUNTC counts number of pipes. Either is possible, just pick the one that does what you need.
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.