Dear all,
How can I put ' and " among ' ' in the following code?
%MACRO CompnayNameM(no=,Company_name=);
Data DATASTREAM3_1&no.;
Set Step9.Datastream_TOTAL_Step3_1;
if findc(&COMPANY_NAME._Step23, '-’”'"#*@!?/&():;,. 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ','K')>0;
keep &COMPANY_NAME. &COMPANY_NAME._Step23;
run;
%MEND CompnayNameM;
%CompnayNameM(no=1,Company_name=NAME)
%CompnayNameM(no=2,Company_name=COMPANY_NAME)
run;
Could you please give me some suggestions? thanks in advance.
There's a general principle involved. When using single quotes to denote a string, refer to a single quote inside the string as two consecutive single quotes. For example:
'A''B'
refers to the same string as:
"A'B"
@Alexxxxxxx wrote:
Dear all,
How can I put ' and " among ' ' in the following code?
%MACRO CompnayNameM(no=,Company_name=); Data DATASTREAM3_1&no.; Set Step9.Datastream_TOTAL_Step3_1; if findc(&COMPANY_NAME._Step23, '-’”'"#*@!?/&():;,. 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ','K')>0; keep &COMPANY_NAME. &COMPANY_NAME._Step23; run; %MEND CompnayNameM; %CompnayNameM(no=1,Company_name=NAME) %CompnayNameM(no=2,Company_name=COMPANY_NAME) run;
Could you please give me some suggestions? thanks in advance.
You might be better off explaining which characters you are actually searching for. You have included in your list things that would appear with the modifiers UDP so the character list is way longer than needed.
Here's a quick example of how to get both single (') and double (") quotes into a string
data _null_ ;
string="abc'def""ghi" ;
put string= ;
run ;
Note because I used double quotes for my string, I needed to use 2 sets of double quotes inside the string
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.
Ready to level-up your skills? Choose your own adventure.