BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Sajid01
Meteorite | Level 14

Hello @Julie99999 
Strip does work inside call execute.

As a reminder Call Execute generates a code that executes after the current data step.
Therefore the arguments to Call Execute should generate a complete SAS code.

The argument to Call Execute as has been posted in this question does not result in a complete  data step code.
Further the instance of variable cbsa_title following the "if" is local to the code generated by call execute and needs to be defined within the code forming the argument of the call execute. Here this local value of cbsa_title is being compared to value of cbsa_title from outside the call execute.
I am giving a sample code below. I have used cbsa_title_local and cbse_title_external to  emphasize the the difference.

data _null_;
IND_COAST="SOMETHING";
cbsa_title_external="PITTSBURGH PA PMSA   ";
call execute(
'data _null_;
cbsa_title_local="PITTSBURGH PA PMSA   ";
if cbsa_title_local ="'||strip(cbsa_title_external )|| '" then IND_COAST = "' ||strip(IND_COAST)||' ";
put IND_COAST=;
run;');
run;

The operative portion of the output from the log shows that strip function works and prints the expected value for IND_COAST.

 
 NOTE: CALL EXECUTE generated line.
 1         + data _null_;cbsa_title_local="PITTSBURGH PA PMSA   ";if cbsa_title_local ="PITTSBURGH PA PMSA" then IND_COAST = 
 "SOMETHING ";put IND_COAST=;run;
 
 IND_COAST=SOMETHING

 

Julie99999
Obsidian | Level 7
thanks for your reply. I didn't post my complete call execute code here, my call execute can run with no problem. The problem is hidden characters in the text string "PITTSBURGH PA PMSA ", which won't work for strip()

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 16 replies
  • 1784 views
  • 7 likes
  • 7 in conversation