1

To get the longest viewing period for a given ID I can use the following code. But, how can I also retrieve the channel that corresponds to the longest viewing period. I apologize for my pathetic attempt at formatting

proc means data=new1 noprint max nway missing; 

   class ID;

   var duration;

   output out=sample_max (drop=_type_ _freq_) max=;

run;
4

1 回答 1

0
proc sort data=have;
by id descending duration ;
run;

data want;
set have;
by id;
if first.id;
run;

这为您提供了最高的持续时间,每个 ID 一个。

您还可以获取 PROC MEANS 输出并将其合并到原始数据集以检索它对应的行(在这种情况下很愚蠢,但如果您想要除 max 之外的其他内容,可能会很有用)。

于 2013-08-05T17:44:06.227 回答