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.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.