Desktop productivity for business analysts and programmers

my sas give me wrong output!!!!!!!!!

Reply
Occasional Contributor
Posts: 5

my sas give me wrong output!!!!!!!!!

hi ,

im writing this

data aosi.BDI59_PITUACHreg2;

if shiuch in (0,2750,2921,4532,5077,5078,5083,5901,5902,6300,6305,9698) then shiuch_m1=1;

else  shiuch_m1=0;

if shiuch in (0,2750,2921,4532,5077,5078,5083,5901,5902,6300,6305,9698) then test_mira=1;

else test_mira=0;

if shiuch in (0,2750,2921,4532,5077,5078,5083,5901,5902,6300,6305,9698) then www=1;

else  www=0;

if shiuch in (0,2750,2921,4532,5077,5078,5083,5901,5902,6300,6305,9698) then mir=1;

else mir=0;

set aosi.BDI59_PITUACH;

run;

proc sql ;

title "shiuch_m1";

select shiuch_m1,sum(keshel) as keshel

from aosi.BDI59_PITUACHreg2

group by 1;

quit;

proc sql ;

title "test_mira";

select test_mira,sum(keshel) as keshel

from aosi.BDI59_PITUACHreg2

group by 1;

quit;

proc sql ;

title "mir";

select mir,sum(keshel) as keshel

from aosi.BDI59_PITUACHreg2

group by 1;

quit;

proc sql ;

title "www";

select www,sum(keshel) as keshel

from aosi.BDI59_PITUACHreg2

group by 1;

quit;


the output is this

shiuch_m1

shiuch_m1keshel
07
157

test_mira

test_mirakeshel
00
164

mir

mirkeshel
07
157

www

wwwkeshel
07
157

please , i think my sas go crazy and im losing my mind

help?

thanks a lot

Super Contributor
Posts: 644

Re: my sas give me wrong output!!!!!!!!!

Try putting the set statement before the if statements.

data aosi.BDI59_PITUACHreg2;

set aosi.BDI59_PITUACH;


if shiuch in (0,2750,2921,4532,5077,5078,5083,5901,5902,6300,6305,9698) then shiuch_m1=1;

else  shiuch_m1=0;

if shiuch in (0,2750,2921,4532,5077,5078,5083,5901,5902,6300,6305,9698) then test_mira=1;

else test_mira=0;

if shiuch in (0,2750,2921,4532,5077,5078,5083,5901,5902,6300,6305,9698) then www=1;

else  www=0;

if shiuch in (0,2750,2921,4532,5077,5078,5083,5901,5902,6300,6305,9698) then mir=1;

else mir=0;

  

run;


Respected Advisor
Posts: 3,124

Re: my sas give me wrong output!!!!!!!!!

If possible, please attach the dataset you were using. you could only post those involving variables.

From first look, it does look bizzar.

Haikuo

Respected Advisor
Posts: 4,962

Re: my sas give me wrong output!!!!!!!!!

When something unexplainable occurs (and this really does fall into that category), it often helps to narrow down where the problem is occurring.  In this case, is it the DATA step, or is it the SQL steps?  Here is one preliminary step you could take to narrow down the issue:

proc freq data=aosi.BD159_PITUACHreg2;

   tables shiuch_m1 * test_mira * www * mir / list missing;

run;

Good luck.

Occasional Contributor
Posts: 5

Re: my sas give me wrong output!!!!!!!!!

thx

Newbie

Respected Advisor
Posts: 4,962

Re: my sas give me wrong output!!!!!!!!!

Aha!  And has anybody figured out why that would make it work?  (answer below)

Answer:

When the SET statement is in the wrong position, the answer will clearly be wrong.  But why should they results be different for one variable out of the four?

One of the variables (test_mira) was created by the programming statements.  But the other three were already part of the original data set.  Placing the SET statement in the wrong place would overwrite the three variables that already existed, but would not overwrite test_mira.

Respected Advisor
Posts: 3,124

Re: my sas give me wrong output!!!!!!!!!

That is an 'Aha' moment! Thanks, Astounding. I think I will stop pulling hair now.

Haikuo

Contributor
Posts: 39

Re: my sas give me wrong output!!!!!!!!!

computer says 'no'..

Ask a Question
Discussion stats
  • 7 replies
  • 317 views
  • 0 likes
  • 5 in conversation