12-31-2014 09:10 AM
Hello, I'm running a SAS program that was put in place before I started at my job. The issue that I'm having is that one of the fields is only being populated on the last unique line. Example below.
I want the CAT field to be populated for every line (not just the final unique line if that makes sense).
Does anyone know what I should look for in my code to fix this? I'm very new to SAS unfortunately.
12-31-2014 10:12 AM
i am not sure if i understood your question correctly
Hope this is the output you are expecting
if this is the case, then please try
proc sort data=have;
by id gr sg descending cat ;
by id gr sg ;
if first.sg then cat_=cat;
12-31-2014 11:33 AM
Incorporating an inline view might make the code easier to follow. E.g.:
create table want (drop=_cat) as
from (select id,cat as _cat,max(cat) as CAT,gr,sg
group by id,gr,sg)
12-31-2014 03:35 PM
Ideally you should fix the code that genarates that table. We can't help without knowing what that code is. But you might simply want to correct for its flaws by adding a step like:
create table want as
select id, max(cat) as CAT, gr, sg
group by id;