10-09-2015 09:56 AM
I have a table and I am trying to compare the the colors. Basically in the datastep... I want the primary color blue to count.. if the primary color blue isn't there I want to count the green... if no green then don't count. I am trying to understand how to write this so the observation looks at the next one
data new; set color_table;
if first.person and color='green' then;
10-09-2015 10:28 AM
Sorry, I am really not following the logic. What do you mean by if blue is not there then count green? Both colors are in the data? If you mean sequentially, then you would need to attribute a distinct sequential order to the data.
10-09-2015 10:37 AM
what I am trying to do is count one color or the other... For Paul.. I want to add 1 if the color is blue.. but if the next record is green.. don't count green..
10-09-2015 11:04 AM
Which then goes back to my previous question as in your test data, blue is clearly there?
Second and last row.
10-09-2015 11:09 AM
10-09-2015 11:24 AM
But what does observation order have to do with anything? If there is a record in the data for that particular group of blue, then there is a records in that particular group = blue, if its the first obs or the 5th doesn't matter. A mere matter of sorting the data appropriately will put the blue in the correct order, so I sort your dataset:
There are Blue records?
10-09-2015 12:03 PM