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
Do you have some data to work with? If so post it to get a code answer
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;
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.
PROC SUMMARY is something that you will use every week. You need to learn it. Here's a link:
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.