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

using Collapse command

$
0
0
Hi.

I'm a beginner and working with Census data. My variables are LOCATION SEX AGE YEAR1, YEAR2, etc..... YEAR20 and I have ages 1-90. My goal is to collapse the ages 80+ into one row but maintain all other ages in their own row. In the end I'll have rows for ages 1, 2, 3, ..... 78, 79, 80+.

I am wondering if there is a way to combine the "if" statement and the collapse command?

The syntax I was using was something like

sort LOCATION SEX AGE
collapse (sum) varlist, by(LOCATION SEX AGE) if AGE>79

But getting errors that if option is not allowed. Thoughts?

Viewing all articles
Browse latest Browse all 72773

Trending Articles



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