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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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