BookmarkSubscribeRSS Feed
gstover
Fluorite | Level 6

I am trying to find a specific string of data in a variable to set a new variable and am having major issues.  

 

Here is the code:

 

string_find = find(indicators, "Educational") ;

if string_find ^=0
then notes='Educational';

 

This is not working.  I am going crazy, please help!

4 REPLIES 4
ballardw
Super User

Example data where that is not working.

 

Some likely issues: your value is a different case than "Educational" such as "educational" or "EDUCATIONAL" or some different combination of upper and lower case letters. If this is the case then add the option "i" to the Find function symtax to make case insensitive comparison:

string_find = find(indicators, "Educational",'i') ;

 

andreas_lds
Jade | Level 19

Having the information you provided, it is hardly possible to help (except for the pointing that all compares in sas are case-sensitive, if you don't use options disabling this), so: Please post data in usable form an the complete step you have written to process the data.

gstover
Fluorite | Level 6

This is the what is in the variable indicators:

 

Exam matched indicator flag;Signed by Attending;PACS transfer complete;Clinical;EMR transfer complete;Completed

 

When I use the following code it marks this record as 'Educational' and it is not.

 

data qpath_us ;
retain MRN CSN full_name exam_type date attending signatory institution indicators notes covered_exam discat ;

length discat $10.
notes $60. ;

set &dsn1 (drop=accession qa_status operator reviewer gender rename=(account=CSN patient_id=MRN)) ;

if CSN ne . ; /*remove temporary ids*/

 

if put (csn,wq9639l.) = '@#%'
then notes='9639' ;

 

if put (csn,wq9640l.) = '@#%'
then notes='9640' ;

 

billing_provider = left(upcase(attending)) ;

 

if put(exam_type,$examfmt.) = '1'
then covered_exam = 'Y' ;
else covered_exam = 'N' ;

 

if find(exam_type,'Procedural')
then discat = 'PROC' ;

else

 

select (exam_type) ;
when ('ED Abdominal Aorta') discat = 'AORTA';
when ('ED FAST Exam') discat = 'FAST';
when ('ED Focused Chest Ultrasound') discat = 'ECHO';
when ('ED Focused Echo') discat = 'ECHO';
when ('ED Renal Ultrasound') discat = 'RENAL';
when ('ED ULTRASOUND EDUCATION') discat = 'EDUCAT' ;
otherwise discat = 'ALL OTHER';
end ;

 

new_indicators = upcase(indicators) ;

if find(new_indicators, "EDUCATIONAL")
then notes = 'Educational';

else

if exam_type = 'ED ULTRASOUND EDUCATION'
then notes = 'Educational' ;

else notes=notes ;

 

if notes = 'Educational'
then covered_exam = 'E' ;

run ;

 

Thanks

 

Gina

 

 

andreas_lds
Jade | Level 19

@gstover wrote:

This is the what is in the variable indicators:

 

Exam matched indicator flag;Signed by Attending;PACS transfer complete;Clinical;EMR transfer complete;Completed

 

When I use the following code it marks this record as 'Educational' and it is not.

 

data qpath_us ;
retain MRN CSN full_name exam_type date attending signatory institution indicators notes covered_exam discat ;

length discat $10.
notes $60. ;

set &dsn1 (drop=accession qa_status operator reviewer gender rename=(account=CSN patient_id=MRN)) ;

if CSN ne . ; /*remove temporary ids*/

 

if put (csn,wq9639l.) = '@#%'
then notes='9639' ;

 

if put (csn,wq9640l.) = '@#%'
then notes='9640' ;

 

billing_provider = left(upcase(attending)) ;

 

if put(exam_type,$examfmt.) = '1'
then covered_exam = 'Y' ;
else covered_exam = 'N' ;

 

if find(exam_type,'Procedural')
then discat = 'PROC' ;

else

 

select (exam_type) ;
when ('ED Abdominal Aorta') discat = 'AORTA';
when ('ED FAST Exam') discat = 'FAST';
when ('ED Focused Chest Ultrasound') discat = 'ECHO';
when ('ED Focused Echo') discat = 'ECHO';
when ('ED Renal Ultrasound') discat = 'RENAL';
when ('ED ULTRASOUND EDUCATION') discat = 'EDUCAT' ;
otherwise discat = 'ALL OTHER';
end ;

 

put 'Starting value ' notes=;

new_indicators = upcase(indicators) ;

 

if find(new_indicators, "EDUCATIONAL") then do;

  put 'new_indicators contains educational';

  notes = 'Educational';

end;

else do;

  if exam_type = 'ED ULTRASOUND EDUCATION' then do;

    put 'exam_type is ED ULTRASOUND...';

    notes = 'Educational' ;

  end;

  else do;

    put 'keeping value of notes';

    notes=notes ;

  end;

end;

 

if notes = 'Educational'
then covered_exam = 'E' ;

run ;

 

Thanks

 

Gina

 

 


I am not that bored to create dataset &dsn1 and fill it with guessed values. That would not make any sense at all. So until you post an excerpt of the data you have, it is difficult to help. The unformatted code you have posted makes reading it unnecessary difficult, too. You should add do...end to the if statements and add some put-statements, to know which assignment sets "notes" to "Educational". See orange text in your code.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 4 replies
  • 698 views
  • 0 likes
  • 3 in conversation