Hi Statalist.
I'm stumped on a what I feel like should be a simple problem. I'm running Stata 18.
I have a dataset with responses to a survey (60 items) from thousands of people from 1,000 organizations (each with an "ID") over the course of three years. Some organizations log only one response, while others log many. I have identified organizations logging over 50 responses, and want to look at their response pattern over years using a simple <tab>. The output I want is to display in red the name of the organization followed by a one-way tab by year.
Let's say orgs 234 498 and 1256 are my suspects (although I have many more). The code that isn't working for me is...
local tagorgs 234 498 1256
foreach num of numlist `tagorgs' {
display in red org_name if ID==`num'
tab year if ID==`num'
}
While this does yield <tab by year> for the three orgs (with IDs 234, 498 and 1256), it only displays a single org name that doesn't match with any of those three organizations.
I'm also concerned that I'm not correctly using a numlist.
Thanks in advance for any help - both with code, as well as any insight on why this isn't working.
I did find a workaround (below) but the output is not as tidy, and I have to review this with a client who's not very quant-friendly.
foreach num of numlist `over50' {
table org_name year if ID==`num', statistic(freq)
}
*
I'm stumped on a what I feel like should be a simple problem. I'm running Stata 18.
I have a dataset with responses to a survey (60 items) from thousands of people from 1,000 organizations (each with an "ID") over the course of three years. Some organizations log only one response, while others log many. I have identified organizations logging over 50 responses, and want to look at their response pattern over years using a simple <tab>. The output I want is to display in red the name of the organization followed by a one-way tab by year.
Let's say orgs 234 498 and 1256 are my suspects (although I have many more). The code that isn't working for me is...
local tagorgs 234 498 1256
foreach num of numlist `tagorgs' {
display in red org_name if ID==`num'
tab year if ID==`num'
}
While this does yield <tab by year> for the three orgs (with IDs 234, 498 and 1256), it only displays a single org name that doesn't match with any of those three organizations.
I'm also concerned that I'm not correctly using a numlist.
Thanks in advance for any help - both with code, as well as any insight on why this isn't working.
I did find a workaround (below) but the output is not as tidy, and I have to review this with a client who's not very quant-friendly.
foreach num of numlist `over50' {
table org_name year if ID==`num', statistic(freq)
}
*
Comment