Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Why the do group is processing even if the condition is not satisfied?

Accepted Solution Solved
Reply
Contributor
Posts: 49
Accepted Solution

Why the do group is processing even if the condition is not satisfied?

Can any one help in this?

data one;

input a b;

datalines;

1 2

2 3

3 4

;

run;

data two;

chk=open('one');

chk1=varnum(chk, 'LINENO');

if chk1 ne 0 then do;

set one;

if LINENO ne 1;

end;

run;

Here the Do group is getting processed and giving note in the log that "Variable LINENO is uninitialised"

Thank you in adnvance.


Accepted Solutions
Solution
‎11-06-2013 11:02 PM
Respected Advisor
Posts: 3,156

Re: Why the do group is processing even if the condition is not satisfied?

Posted in reply to devarayalu

data _null_;

chk=open('one');

chk1=varnum(chk, 'LINENO');

if chk1 ne 0 then call execute(' data two; set one; if lineno ne 1; run;');

run;

View solution in original post


All Replies
Super User
Super User
Posts: 7,059

Re: Why the do group is processing even if the condition is not satisfied?

Posted in reply to devarayalu

SAS compiles the whole data step. So even though the line that references the variable LINENO is inside of a DO loop that will never execute SAS will still create the variable in the program data vector.  Hence the warning about the variable never being initialized.

Contributor
Posts: 49

Re: Why the do group is processing even if the condition is not satisfied?


ok thank you and can you please also guide me how to get rid of the message. without changing the if condition

Solution
‎11-06-2013 11:02 PM
Respected Advisor
Posts: 3,156

Re: Why the do group is processing even if the condition is not satisfied?

Posted in reply to devarayalu

data _null_;

chk=open('one');

chk1=varnum(chk, 'LINENO');

if chk1 ne 0 then call execute(' data two; set one; if lineno ne 1; run;');

run;

Contributor
Posts: 49

Re: Why the do group is processing even if the condition is not satisfied?

Thank you so much for the prompt answer

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 279 views
  • 0 likes
  • 3 in conversation