BookmarkSubscribeRSS Feed
Candrews
Calcite | Level 5

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.

 

 

 

 

 

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

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

Reeza
Super User

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. 

 

 

Candrews
Calcite | Level 5

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.

Marina
Calcite | Level 5

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?

 

Astounding
PROC Star

I'm betting on something simple and obvious like degree_level is actually "d" rather than "D"

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 5 replies
  • 867 views
  • 1 like
  • 5 in conversation