BookmarkSubscribeRSS Feed
Malewar
Fluorite | Level 6

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
5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

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

Malewar
Fluorite | Level 6
No actually I don't have any data on my local machine. Apologies for the inconvenience.
Astounding
PROC Star

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;

 

Malewar
Fluorite | Level 6

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.

 

 

 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 704 views
  • 1 like
  • 3 in conversation