** This post references a previous forum discussion (https://www.statalist.org/forums/node/1484556) but is posted separately because it seems to deal with a sufficiently separate sub-issue. Please advise or link if the post should be continued under the previous thread.
I have been working with data using code that includes the very handy 'runby' module, which performs a program, looping over data by-groups. In my case, the code (written by Clyde Schechter and available here) performs matrix multiplication over a set of groups. The code works as expected for some of the data but there are many exceptions/errors. The error appears to result from some problem runby encounters when looping over certain group variables. For the below data, for example, the matrix multiplication operation is performed for three of the four groups: 1714081, 1714201 and 1714351 but *not* for one of the groups: 1714251, as indicated by the report appearing below the data.
The problem seems to be with the specific values of the group variable (i.e. observations 1714251). However, I examined the data type for these observations and it matches the other observations. I also examined the data structure for other variables associated with the 'errant' observations and the structure seems no different than other observations. However, the problem is not solved by simply changing the group id values to 001, 002, 003, 004. Whatever the problem, it is systematic and occurs for 1,096 of the 1,136 groups my data. I'd appreciate any help.
Thanks.
* Example generated by -dataex-. To install: ssc install dataex
clear
input long groupid byte(v1 v2 v3 v4 v5 v6 v7 v8 v9 v10)
1714081 0 0 0 1 0 0 1 0 0 0
1714081 1 1 1 1 1 1 1 0 1 0
1714081 0 0 0 0 0 0 0 0 0 0
1714201 1 1 1 1 0 0 1 0 1 1
1714201 0 0 0 0 0 0 0 0 0 0
1714201 0 0 0 0 0 0 0 0 0 0
1714201 1 1 1 1 1 1 1 0 0 1
1714201 1 1 1 1 1 1 1 0 1 1
1714201 1 1 1 1 1 1 1 0 1 1
1714251 0 0 1 1 1 0 1 0 1 0
1714251 1 1 1 1 0 1 1 0 0 1
1714251 1 1 1 1 1 0 1 0 1 1
1714251 1 1 1 1 0 0 1 0 1 0
1714251 1 1 1 1 1 0 1 0 0 0
1714251 1 1 1 1 1 1 1 0 0 1
1714251 0 0 0 1 0 0 0 0 0 0
1714251 0 0 0 0 0 0 1 0 0 0
1714251 1 0 1 1 1 1 1 0 0 1
1714251 1 1 1 1 1 0 1 0 1 0
1714251 1 1 1 1 1 1 1 0 1 0
1714351 0 1 1 0 0 0 0 0 0 0
1714351 0 0 0 0 0 0 0 0 0 0
1714351 1 1 1 1 1 0 1 0 0 1
1714351 1 1 1 1 0 0 0 0 0 0
1714351 1 0 0 1 0 0 0 0 0 1
1714351 1 1 1 1 1 0 1 0 0 1
1714351 0 1 0 1 0 0 0 0 1 0
1714351 1 1 1 1 1 0 1 1 0 1
1714351 0 1 1 0 0 0 1 0 0 0
1714351 1 1 1 1 0 0 1 0 1 1
end
[CODE]
. runby one_group, by(groupid)
--------------------------------------
Number of by-groups = 4
by-groups with errors = 1
by-groups with no data = 0
Observations processed = 30
Observations saved = 19
--------------------------------------
Related Posts with runby: requirements for group variable?
Using loop to replace values in a variableDear All, I am new to loop. Is there a way I can replace the missing values with the number 1 each …
How to Clean String variable with errors in data entryHi Stata Forum, I am a relatively new user to STATA. I am working on a project that uses data scrap…
Generating Variables Acc. to Multiple Conditions And Earliest OccurrenceI am working with a dataset that contains names, the frequency of a name according to gender, and th…
Whether can I do two mean difference tests simultanuously?Dear Statalists, My dataset has 4 variables A, B, C and D. I would like to test mean difference of …
Why the variables'name from esttab presentation is different from that of presented table by using esttabMy code is as below Code: reghdfe wNET_PRO_MAR pt , a(TYPE2 yr) est sto m1 reghdfe wNET_PRO_MAR …
Subscribe to:
Post Comments (Atom)
0 Response to runby: requirements for group variable?
Post a Comment