Statistics SAS数据组织
我有数据集,如附件中的图片,我只需要每年具有相同numsecur的观测值Statistics SAS数据组织,statistics,sas,stata,analysis,Statistics,Sas,Stata,Analysis,我有数据集,如附件中的图片,我只需要每年具有相同numsecur的观测值 如何在SAS proc sql函数中执行此操作?在斯塔塔这样做会更容易吗?如果是这样的话,我可以使用什么程序?您看起来像是stackoverflow的新用户。欢迎你的问题被否决至少有三个原因: 1) It's not really clear what you want from your description of the problem and the data you're providing 2) You
如何在SAS proc sql函数中执行此操作?在斯塔塔这样做会更容易吗?如果是这样的话,我可以使用什么程序?您看起来像是stackoverflow的新用户。欢迎你的问题被否决至少有三个原因:
1) It's not really clear what you want from your description of the problem and the data
you're providing
2) You haven't shown any attempts at what you've tried
3) Providing your data as a picture is not great. It's most helpful if you're going
to provide data to provide it so it's easy for others to consume in their program.
After all, you're asking for our help make it easier for us to help you. If You
included something like the following we just have to copy and paste to create your
dataset to work with:
DATA test;
INPUT ID YEAR EXEC SUM;
DATALINES;
1573 1997 50 1080
1581 1997 51 300
1598 1996 54 80
1598 1998 54 80
1598 1999 54 80
1602 1996 55 112.6
1602 1997 55 335.965
;
RUN;
尽管如此,以下内容可能会告诉你你在寻找什么,但这只是一个猜测,因为我不确定这是否真的是你在问的问题:
proc sql no print;
create table testout as
select *,count(*) as cnt
from test
group by sum
having cnt > 1;
quit;
您的问题是:显示使用相同金额的所有行还是其他行?假设我正确理解您的问题,您希望保留来自同一公司/个人的观察结果,前提是该公司每年的numsecur相同。下面是我将尝试使用STATA的内容:
input ID YEAR EXEC SUM
1573 1997 50 1080 //
1581 1997 51 300 //
1598 1996 54 80 //
1598 1998 54 80 //
1598 1999 54 80 //
1602 1996 55 112.6 //
1602 1997 55 335.965 //
1575 1997 50 1080 //
1575 1998 51 1080 //
1595 1996 54 80 //
1595 1998 54 30 //
1595 1999 54 80 //
1605 1996 55 112.6 //
1605 1997 55 335.965 //
end
bysort ID SUM: gen drop=cond(_N==1, 0,_n)
drop if drop==0
结果显示(根据我的数据):
ID年执行总额下降
1.1575 1997 50 1080 1
2.1575 1998 51 1080 2
3.1595 1999 54 80 1
4.1595 1996 54 80 2
5.1598 1996 54 80 1
6.1598 1998 54 80 2
7.1598 1999 54 80 3
对不起,我没有看到一张照片。。。您可以不使用代码块吗?因此,对于您的示例,您只需要1998年和1999年?是的,在本示例中,我需要ID为001598的199619981999年的观测值。如果您单击标题,您将看到该表,您可以提供一个您希望最终数据集的具体示例吗?很难理解你在问什么。谢谢你的回答,我应该在我的问题上说得更清楚。我真的想要你说的。至于我的尝试,我创建了一个滞后变量,然后在滞后和numsecur之间创建了一个差分变量;然后,我删除了除零以外的观察值。如果我的答案对您有效,请单击复选标记接受答案,然后单击上三角。感谢您的回答。我很乐意提供帮助! ID YEAR EXEC SUM drop 1. 1575 1997 50 1080 1 2. 1575 1998 51 1080 2 3. 1595 1999 54 80 1 4. 1595 1996 54 80 2 5. 1598 1996 54 80 1 6. 1598 1998 54 80 2 7. 1598 1999 54 80 3