I am having trouble with my sas code, specifically with this line:
else if substr(major1,1,6) in ('422704','422801') and degree_level='D' then isSTEMH1='Y'; The full data step code is in the attached word document.
I know for a fact that there are records with these CIP codes and it is not classifying them correctly when i run the full data step.
Can you provide some sample data? 🙂
Also it is easier for us if you post your code directly using the running guy at the top
Post your code directly into the forum using a code block please.
I think it's a logical error - your data is meeting a classification in a IF statement before the IF statement you're trying to assign.
IF statements are evaluated in order, and if one is evaluated as TRUE then it exits the IF block.
Verify your logic.
If you need further help, please post some sample data - ideally records from your data that you know should work but aren't and include the code/log and output you expect vs what you get.
I tried moving the if statement to the beginning of the data step and still no luck. I will try to post a sample data set.
Reeza is right, there are few problems with your IFstatement.
For example, you are evaluating string '13120601' three times:
- in the very first IF, in conjunction with fice and academic_year,
- then few ELSE IFs later - just '13120601';
- and in the next line - first six characters of it - '131206' and fice='00200200'.
It would really be helpful to know what question are you trying to answer? Do you need to know three things - first major was STEM-H, second major was STEM-H, any of the majors was STEM-H? Or just one - any of the majors was STEM-H?
I'm betting on something simple and obvious like degree_level is actually "d" rather than "D"
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 25. Read more here about why you should contribute and what is in it for you!
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.