BookmarkSubscribeRSS Feed
amitosi
Calcite | Level 5

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

7 REPLIES 7
RichardinOz
Quartz | Level 8

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;


Haikuo
Onyx | Level 15

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

From first look, it does look bizzar.

Haikuo

Astounding
PROC Star

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.

amitosi
Calcite | Level 5

thx

Newbie

Astounding
PROC Star

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.

Haikuo
Onyx | Level 15

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

Haikuo

moorsd
Obsidian | Level 7

computer says 'no'..

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 7 replies
  • 1120 views
  • 0 likes
  • 5 in conversation