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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.