I have cigarette smoking data along with a continuous variable of interest. I compute how many cigs were smoked in the last 15, 30 and 60 minutes before the measure was taken. It turns out the the number of cigs smoked in the last 15 minutes is 0, 1 or 2, in the last 30 minuts is 0, 1, 2 or 3 and in the last 60 minutes is 0, 1, 2, 3, 4 or 5. Okay, that's all fine.
Then what I want to do is make a vertical bar chart. On the y-axis is the mean measure of interest and on the x-axis is separate bars for the number of cigs smoked. I'm using PROC GCHART. When I do it for 15 minutes it works fine and vertical bars at 0, 1 and 2 show up. When I do it for 60 minutes it works fine and vertical bars for 0, 1, 2, 3, 4 and 5 show up. Okay, still fine.
But when I do it for 30 minutes, instead of getting vertical bars at 0, 1, 2 and 3 as I should, I get vertical bars at only 0 and 3. (As an aside, although it works for 15 and 60 minutes, the x-axis ticks don't say 0, 1, 2, etc and instead say 0.0, 1.0, 2.0, etc. Maybe that's a clue in all this.)
In an AXIS statement my code has the line
order = 0 to 5 by 1;
But the bars for 1 and 2 don't show up. (Or if I change 5 to 3 then the same thing happens.)
Then I tried order = 0 to 5 by 0.1 and still the bars for 1 and 2 didn't show up.
Then I tried 0 to 5 by 0.01 and the bars for 1 and 2 DID show up. It's all squished together because I have so many points on the x-axis so I can't tell exactly where they're at, be it 1.99 or 2.01 or whatever, but the bars at (or close to) 1 and 2 are there.
Why is this? I want to use 0 to 5 by 1 (or maybe 0 to 3 by 1) and have bars at 0, 1, 2 and 3, but I can't seem to accomplish this, I guess because SAS somehow thinks the value aren't exactly 1 and 2.
I did a PROC FREQ with a format 30.28, to see 28 numbers to the right of the decimal for 0, 1, 2 and 3 and every single number to the right of the decimal is 0, e.g., it's 2.0000000000000000000000000000 rather than something else.
Any ideas? When I created these numbers I set a counter to 0 and then if a person smoked I cig I incremented the counter by 1 so I don't see how the values can be anything other than exactly 0, 1, 2 or 3.
Any info is appreciated.
Signed,
Mystified in Chapel Hill
... View more