I have the following problem. I have a string variable which i want to search for a list of specific expressions with the help of the count function. My expressions contain sometimes "," or "(" or ")" or other signs which result in an error for this function. I checked the documentation for the count function, however it sounds like greek to me
How do I have to specify the function in order to work properly with these other signs?
thanks for your answer. However, I think I didn't make my question clear enqough. Sorry for that! I'm searching in a variable for a list of expressions (the list is a macro variable that contains expressions which are delimited by a "*" and each word is searched with the help of a loop), and some of these expressions contain closed or open brackets as well as commas (e.g., "have, in the past,"). When I search for these expressions in a macro (text is the variable I am searching) with
then SAS gives back an error: "More positional parameters found than defined."
sas macro processing is designed to mingle program instructions with data,
and you are expected to provide control when there might be doubt like whether [pre]("have, in the past,"). [/pre] provides program or data.
The macro quoting fuinctions are intended to provide this control.
If your data in the list in the macro variable are reliable, then %str(&list) might
provide enough protection, otherwise use stronger quoting, like:
%superQ(list) and %Qscan(%superQ(list), &count, &delim)
I made some changes in the code. Now it works but what is the output? count?
%do %while (%length(&express) ne 0);
%let count_gen_&count = countc(&list,"&express",'w') ;
%let count=%eval(&count + 1);
I will try once again to make clear what my problem is.
I have a dataset that includes a variable with the name "text" and I have a list of expressions (this list is given by the macro variable "generals"). Now the task I want to perform is to generate one variable in my initial dataset for each expression in "generals" that gives back the number of times that expression appears in the variable "text".
This works as long as there are no commas or brackets in the expression list.
I will try to give you a simplified version of my full code:
length text $ 50;
input Text $;