BookmarkSubscribeRSS Feed
yzs0056
Calcite | Level 5

Hello,

I am a beginner in SAS, I hope I can get some help from the community.

I am trying to calculate the industry median R&D expense for each year excluding the focal firm, the industry is indicated by the 4-digit SIC code.

For example, assume the data is from 2000-2005 for 10 firms: A, B, C, D, E have same SIC code, and F, G, H, I, J have the same SIC code,  each firm has data covering those 6 years, how do I get the industry median RD expenses excluding each focal firm for each industry and year?

 

Thanks so much!

 

yzs0056

1 REPLY 1
mkeintz
PROC Star

Some questions:

  1. Do you want total-period medians over all 6 years, or do you want yearly "complimentary" medians?  By "complimentary" I mean excluding the company in hand.
  2. Could you show, in a data step, a sample of what your incoming data looks like?
  3. Are your data sorted by SIC (probably not, but it's worth knowing).

 

The crude way of doing this is to output each company's data N(sic)-1 times, where N(sic) is the number of industries in a given SIC.  And output it in such a way that there are N(sic) group id's (variable GROUPID), such that company i is not in groupid=I.  Then tell SAS to run a proc to generate medians for each sic/year/groupid.  Finally match those median to the company data.

 

How big is your dataset, i.e. how many total company/years do you have?

 

Edited addition:  And how many SIC's do you have?  Then we would know the average size of each SIC, and the number of times a median must be calculated.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 557 views
  • 0 likes
  • 2 in conversation