How do you find the position of whitespace in a macro variable? For example,
%let someString = the quick brown fox;
%let nextSpace = %index(&someString,' ');
The above code doesn't work. &nextSpace
will be equal to 0. However, I suspect there should be a way to find the position of a space in a macro variable.
Many thanks!
Re: check if macro variable is null Here's the simple way: %if %length(&a)=0 %then %do; Good luck.
You can also use a %PUT Macro Statement to view available macro variables. %PUT provides several options that enable you to view individual categories of macro variables. The system option SYMBOLGEN displays the resolution of macro variables.
After a macro variable is created, you typically use the variable by referencing it with an ampersand preceding its name (&variable-name), which is called a macro variable reference. These references perform symbolic substitutions when they resolve to their value. You can use these references anywhere in a SAS program.
%let nextSpace = %index(&someString,%str( ));
Quotes don't work in macro variables, of course. You need to use macro quoting, such as %str
in this case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With