DATA Step, Macro, Functions and more

SAS coding problem

Reply
New Contributor
Posts: 2

SAS coding problem

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.

 

 

 

 

 

PROC Star
Posts: 766

Re: SAS coding problem

Can you provide some sample data? Smiley Happy

 

Also it is easier for us if you post your code directly using the running guy at the top

Super User
Posts: 19,869

Re: SAS coding problem

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. 

 

 

New Contributor
Posts: 2

Re: SAS coding problem

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.

Contributor
Posts: 21

Re: SAS coding problem

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?

 

Super User
Posts: 5,516

Re: SAS coding problem

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

Ask a Question
Discussion stats
  • 5 replies
  • 181 views
  • 1 like
  • 5 in conversation