Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 73335

Multiplying observations within a variable conditionally

$
0
0
Hi all,

I have a question regarding the multiplication of certain observations within my variables. I'll explain it. I have a variable LoanPayments and a variable PaymentFrequency (string variable). The payment frequency is either monthly, quarterly or semiannual. I would like to make a new variable that equals the annual loan payments. So I thought of something in this way but it does not seem to work like this in stata unfortunately:

gen LoanPaymentsAnn = LoanPayments
replace LoanPayments=LoanPayments*12 if PaymentFrequency=="Monthly"
replace LoanPayments=LoanPayments*2 if PaymentFrequency=="SemiAnnual"
replace LoanPayments=LoanPayments*4 if PaymentFrequency=="Quarterly"

Now you guys probably have a feeling of what I want to do and I couldn't find anywhere how to do this.
Tips??

Would appreciate it!

Regards,

Fabian

Viewing all articles
Browse latest Browse all 73335

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>