Count the number of times the string ‘ ? ‘ occurs in variable line. Choose any method that works reliably. Regardless of method, assume that a line won’t consist entirely of ‘ ? ‘’s.
Easy enough to test a function. Find the required parameters from the documentation of function and then use it. A vast majority of the functions in the SAS documentation have at least one example.
From Countc:
data test; string = 'Baboons Eat Bananas '; a = countc(string, 'a'); b = countc(string, 'b'); b_i = countc(string, 'b', 'i'); abc_i = countc(string, 'abc', 'i'); /* Scan string for characters that are not "a", "b", */ /* and "c", ignore case, (and include blanks). */ abc_iv = countc(string, 'abc', 'iv'); /* Scan string for characters that are not "a", "b", */ /* and "c", ignore case, and trim trailing blanks. */ abc_ivt = countc(string, 'abc', 'ivt'); run;
Key part are the source, the variable String above, and the character list to search for, the second parameter. The 3rd optional parameter has to do with ignoring letter case, adding or excluding certain types of characters that are hard to type and keep in code such as Tab or control characters (ancient stuff from teletype but include things like the "ring bell", vertical space without end of line, and stuff)
So what strategies, in words, do you think might work?
I would think the countc function. We were not provided data to test it on so i'm not sure how it would work.
Easy enough to test a function. Find the required parameters from the documentation of function and then use it. A vast majority of the functions in the SAS documentation have at least one example.
From Countc:
data test; string = 'Baboons Eat Bananas '; a = countc(string, 'a'); b = countc(string, 'b'); b_i = countc(string, 'b', 'i'); abc_i = countc(string, 'abc', 'i'); /* Scan string for characters that are not "a", "b", */ /* and "c", ignore case, (and include blanks). */ abc_iv = countc(string, 'abc', 'iv'); /* Scan string for characters that are not "a", "b", */ /* and "c", ignore case, and trim trailing blanks. */ abc_ivt = countc(string, 'abc', 'ivt'); run;
Key part are the source, the variable String above, and the character list to search for, the second parameter. The 3rd optional parameter has to do with ignoring letter case, adding or excluding certain types of characters that are hard to type and keep in code such as Tab or control characters (ancient stuff from teletype but include things like the "ring bell", vertical space without end of line, and stuff)
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.