在 SAS 中组合数据集而不丢失观测值
嘿伙计们, 我知道,另一个帖子另一个问题:D :(。
我拍了一张截图来轻松解释我的问题。
http: //i39.tinypic.com/rhms0h.jpg
如您所见,我想(再次)合并两个表,我想要实现的结果显示在右下角的表中。我正在计算分析师表中每个月的分析师和女性分析师的总数。在基表中,我对一家公司(这里是股票代码为 AA 的美国铝业公司)有不同的观察结果
data want;
merge base analyst;
by month ;
run;
。我在主表中的观察结果被缩小到只有 4 个观察结果(对于每个不同的年份,2001 年、2002 年、2005 年、2006 年),我想要的是观察结果不会减少,而是每个观察结果都会减少。年相同的数据被放置,如右下角所示,我的合并命令中缺少什么? 在这两个表中,我都将月份作为时间计数变量(我的基表中的观察结果是每月),我需要对其进行合并。为了清楚起见,我添加了 SAS 中真实数据库的 2 个屏幕截图。
基表:
http://i42.tinypic.com/dr5jky.jpg
分析师表:
http://i40.tinypic.com/eqpmqq.jpg
这是我的合并表看起来像:
http://i43.tinypic.com/116i62s.jpg
可以清楚地看到合并后的表只剩下 AA 的四个观察值(每个独特的年份一个),而不是原来的 8 个。
有人有解决这个问题的想法吗?
Hye guys,
I know, another post another problem :D :(.
I took a screenshot to easily explain my problem.
http://i39.tinypic.com/rhms0h.jpg
As you can see I want to merge two tables (again), the Base & Analyst table. What I want to achieve is displayed in the right bottom corner table. I’m calculating the number of total analysts and female analysts for each month in the analyst table. In the base table I have different observations for one company (here company Alcoa with ticker AA). When I use the following command:
data want;
merge base analyst;
by month ;
run;
I get the right up corner problem. My observations in the main table are being narrowed down to only 4 observations (for each different year one observation, 2001, 2002, 2005, 2006). What I want is that the observations are not reduced but that for every year the same data is being placed as shown in the right bottom corner. What am I missing in my merge command?
In both tables I have month as a time count variable ( the observations in my base table are monthly) on which I need to merge. For clarity I added 2 screenshots of my real databases in SAS.
The base table:
http://i42.tinypic.com/dr5jky.jpg
The analyst table:
http://i40.tinypic.com/eqpmqq.jpg
Here is what my merged table looks like:
http://i43.tinypic.com/116i62s.jpg
You can clearly see that the merged table only has four observations left for AA (one for each unique year) instead of the original 8.
Anyone an idea to solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
呃,看来你可以通过合并股票和月份来轻松解决这个问题。
/耻辱。
Ugh, it appears you can easily solve this by merging on both ticker and month.
/shame.