Hi
edu = FINDC(Education,"MD");
Datalines
Ptid EDucation
1. MD,DO
2. MD
3. PHD
How I want to code
Ptid EDucation edu
1. MD,DO 1
2. MD 1
3. PHD 0
edu = Find(Education, "MD")
What is your question?
The code is not working. Can you help come up with a code that give me the output as displayed above.
edu = find(EDucation,'MD')>0;
Why are you using the findC function, which searches for single characters?
Rather use find, which searches for strings, or findw, which searches for words.
Hi @knargis160
data have;
input Ptid $ EDucation $;
edu = FINDC(Education,"MD");
edu1 = FIND(Education,"MD");
edu2 = FINDW(Education,"MD");
datalines;
1. MD,DO
2. MD
3. PHD
;
run;
In the above code:
In your example, FIND and FINDW are equivalent, but if you had "MD" has part of a word, it would give different results.
NB: if you want to make a broader search and look at MD / md / MD / Md, you can add the 'i' modifier:
edu = FIND(Education,"MD","i");
or
edu = FINDW(Education,"MD"," ,","i");
Best,
Is it possible you have an old version of SAS. Find was introduced with version 9. Try Index
data x;
input Ptid Education $char10.;
edu_f = FIND(Education,"MD")>0;
edu_i = INDEX(Education,"MD")>0;
Datalines ;
1. MD,DO
2. MD
3. PHD
;
proc print;run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.