DATA Step, Macro, Functions and more

How to create an index of the funded share to population share

Reply
Occasional Contributor
Posts: 6

How to create an index of the funded share to population share

[ Edited ]

How to create an index of the funded share to population share


a. How do I create a variable for the ratio of each state’s population to total US population. Consider the variable name "Popshare".

b. How do I create a variable that has the ratio of total funded-amnt by state divided by total funded_amnt across all observations. Consider the variable name "Loanshare"
c. How do I put both of these share variables by state in one dataset, and divide loanshare by popshare.

 

By Using above  datasets I wanted to find following 

1. How many states have ratios of > 1 

2. Which state has the highest ratio

 
 
Regards,
Roshan Malewar
PROC Star
Posts: 1,209

Re: How to create an index of the funded share to population share

Do you have some data to work with? If so post it to get a code answer

Occasional Contributor
Posts: 6

Re: How to create an index of the funded share to population share

No actually I don't have any data on my local machine. Apologies for the inconvenience.
Super User
Posts: 6,629

Re: How to create an index of the funded share to population share

Here's an approach to create the pieces you will need.  Presumably you can take care of the data manipulation steps.

 

proc summary data=have;

class state;

var population funded_amt;

output out=stats (drop=_freq_) sum=state_population state_funded_amt;

run;

 

data next_step;

if _n_=1 then do;

   set stats (where=(_type_=0) rename=(state_population=total_population state_funded_amt=total_funded_amt));

end;

set stats (where=(_type_=1));

drop _type_;

run;

 

Occasional Contributor
Posts: 6

Re: How to create an index of the funded share to population share

Posted in reply to Astounding

Actually I'm not able to understand the code

 

proc summary data=have;

class state;                              -------------> Why We use this

var population funded_amt;    ------------> Do we need to create new variable named Population(Getting error that variable Population Not Found)

output out=stats (drop=_freq_) sum=state_population state_funded_amt;          ---------> This is difficult for me to understand

run;

 

Due to this I'm not able to move further. Please do the needful. Waiting for your replay.

 

 

 

 

Super User
Posts: 6,629

Re: How to create an index of the funded share to population share

PROC SUMMARY is something that you will use every week.  You need to learn it.  Here's a link:

 

http://documentation.sas.com/?docsetId=proc&docsetTarget=p0aq3hsvflztfzn1xa2wt6s35oy6.htm&docsetVers...

 

Ask a Question
Discussion stats
  • 5 replies
  • 96 views
  • 1 like
  • 3 in conversation