SAS-当组中的其他变量更改时,计数变量增加增加

发布于 2025-02-08 05:19:21 字数 686 浏览 2 评论 0原文

我基本上是在尝试按2个变量进行分组并执行一个proc SQL的含义,但是由于以下原因,我的小组无法工作:以下是我试图获得的示例(假设这里的数据已正确排序)

现在我知道这不是平均功能的工作方式,因此我尝试考虑解决问题的方法,并且我发现这将有效:

“我试图获得” <<<< /a>

,但是我不知道如何获得。 我已经尝试过

data want; 
set have;
count + 1; 
by User Var X; 
if first.User then count = 1;
run;

,但是这似乎并没有完成技巧。关于如何解决这个问题的想法?

感谢您的阅读!

I am basically trying to group by 2 variables and perform a proc sql mean, however my group by won't work for the following reason : here's an example of what I am trying to get (Assuming the data here is sorted properly)

What I'm trying to get

Now I know that this is not how the mean functions work so I've tried thinking about ways to resolve my issue and I've found that this would work :

What I am trying to get

However I don't know how I could obtain that.
I have tried

data want; 
set have;
count + 1; 
by User Var X; 
if first.User then count = 1;
run;

However this does not seem to get the trick done. Any ideas on how to resolve this ?

Thanks for reading !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

总攻大人 2025-02-15 05:19:21

像这样?

data have;
input user $ varx value average;
datalines;
A 5  150 200 
A 5  250 200 
A 10 500 500 
A 10 500 500 
A 10 500 500 
A 5  50  50  
A 5  50  50  
A 20 10  10  
;

data want;
   set have;
   by user varx notsorted;
   if first.varx then count + 1;
run;

Like this?

data have;
input user $ varx value average;
datalines;
A 5  150 200 
A 5  250 200 
A 10 500 500 
A 10 500 500 
A 10 500 500 
A 5  50  50  
A 5  50  50  
A 20 10  10  
;

data want;
   set have;
   by user varx notsorted;
   if first.varx then count + 1;
run;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文