I'm attaching a do file and a stripped down data file. Somehow an extraneous _ (underscore) is being prefixed to a macro. I tested dropping the EventID that failed and it just produced the error for the next one in line.
The code worked fine for one group of EventIDs with their associated descstd and EventDate, but failed for another group. I can't see the problem.
It would not let me attach the log file for some reason.
Here is what the log file says
name: final
log: C:\00Oliver\Projects\MPEDS\Jena\Jena_event_article _bugproblem_2024-10-26_final.log
log type: text
opened on: 26 Oct 2024, 20:06:29
. version
version 18.5
. clear
. clear
. use jena_fordebugging.dta
. ** this code works fine
. levelsof EventID if EventDate<td(1jan2007), local(evlist)
500 510 515 516 517 522 1609 1648 2227 3802 4764 10213 10217 10220 10224 10225 10241 10242 10243
. foreach eid in `evlist' {
2. levelsof evnamedate if EventID==`eid', local(evlab) clean
3. local evlab=substr("`evlab'",1,31)
4. gen `evlab'=EventID==`eid'
5. *label var q`eid' "`evlab'"
. }
z20061130Jena_arson
z20061208Jena_charges
z20061201Jena_fight061201
z20061202Jena_fight061202
z20061204Jena_fight061204
z20060901Jena_noose
z20060906Jena060906_noose_protest
z20060905Jena060905_ChurchRally
z20060911Jena_schoolboard
z20060906Jena_SchoolAssembly060906
z20061202Jena_ShotgunConfrontation_061202
z20060831Jena_sit_tree060831
z20060831Jena_askpermission_060830
z20060908Jena6_noose_punish
z20060920Jena_sporadic_0609
z20061001Jena06_rifle_school
z20060913JenaTimesarticle0609
z20060918Jena060918_schoolboard
z20061206Jena0612_sickout
.
. *this code introduces an extraneous _ in front of the names being created at a certain point.
. * if I try dropping EventID==9357, it just fails on the next one
. levelsof EventID if EventDate>td(31dec2006) & EventDate<td(1sep2007), local(e07list)
497 498 508 518 4778 6141 9357 9358 10227 10232 10234 10235 10246
. local early07list ""
. *set trace on
. foreach eid in `e07list' {
2. levelsof evnamedate if EventID==`eid', local(evlab) clean
3. local `evlab'=substr("`evlab'",1,29)
4. local evlab =subinstr("`evlab'","_","",1)
5. disp "`eid' `evlab'"
6. gen `evlab'=EventID==`eid'
7. local early07list "`early07list' `evlab'"
8. disp "fulllist `early07list'"
9. }
z20070731Jena_070731_petition
497 z20070731Jena070731_petition
fulllist z20070731Jena070731_petition
z20070731Jena_070731_protest
498 z20070731Jena070731_protest
fulllist z20070731Jena070731_petition z20070731Jena070731_protest
z20070628Jena_Belltrial07
508 z20070628JenaBelltrial07
fulllist z20070731Jena070731_petition z20070731Jena070731_protest z20070628JenaBelltrial07
z20070801Jena_internet
518 z20070801Jenainternet
fulllist z20070731Jena070731_petition z20070731Jena070731_protest z20070628JenaBelltrial07 z20070801Jenainternet
z20070101AlanBeanTrips_Jena07
4778 z20070101AlanBeanTripsJena07
fulllist z20070731Jena070731_petition z20070731Jena070731_protest z20070628JenaBelltrial07 z20070801Jenainternet z20070101AlanBeanTripsJena07
z20070815NAACP_JenaSix07
6141 z20070815NAACPJenaSix07
fulllist z20070731Jena070731_petition z20070731Jena070731_protest z20070628JenaBelltrial07 z20070801Jenainternet z20070101AlanBeanTripsJena07 z20070815NAACPJenaSix07
z20070809Jena6Sharpton_070809_Crthouse
_z20070809Jena6Sharpton_070809_Crthouse invalid name
r(198);
end of do-file
r(198);
The code worked fine for one group of EventIDs with their associated descstd and EventDate, but failed for another group. I can't see the problem.
It would not let me attach the log file for some reason.
Here is what the log file says
name: final
log: C:\00Oliver\Projects\MPEDS\Jena\Jena_event_article _bugproblem_2024-10-26_final.log
log type: text
opened on: 26 Oct 2024, 20:06:29
. version
version 18.5
. clear
. clear
. use jena_fordebugging.dta
. ** this code works fine
. levelsof EventID if EventDate<td(1jan2007), local(evlist)
500 510 515 516 517 522 1609 1648 2227 3802 4764 10213 10217 10220 10224 10225 10241 10242 10243
. foreach eid in `evlist' {
2. levelsof evnamedate if EventID==`eid', local(evlab) clean
3. local evlab=substr("`evlab'",1,31)
4. gen `evlab'=EventID==`eid'
5. *label var q`eid' "`evlab'"
. }
z20061130Jena_arson
z20061208Jena_charges
z20061201Jena_fight061201
z20061202Jena_fight061202
z20061204Jena_fight061204
z20060901Jena_noose
z20060906Jena060906_noose_protest
z20060905Jena060905_ChurchRally
z20060911Jena_schoolboard
z20060906Jena_SchoolAssembly060906
z20061202Jena_ShotgunConfrontation_061202
z20060831Jena_sit_tree060831
z20060831Jena_askpermission_060830
z20060908Jena6_noose_punish
z20060920Jena_sporadic_0609
z20061001Jena06_rifle_school
z20060913JenaTimesarticle0609
z20060918Jena060918_schoolboard
z20061206Jena0612_sickout
.
. *this code introduces an extraneous _ in front of the names being created at a certain point.
. * if I try dropping EventID==9357, it just fails on the next one
. levelsof EventID if EventDate>td(31dec2006) & EventDate<td(1sep2007), local(e07list)
497 498 508 518 4778 6141 9357 9358 10227 10232 10234 10235 10246
. local early07list ""
. *set trace on
. foreach eid in `e07list' {
2. levelsof evnamedate if EventID==`eid', local(evlab) clean
3. local `evlab'=substr("`evlab'",1,29)
4. local evlab =subinstr("`evlab'","_","",1)
5. disp "`eid' `evlab'"
6. gen `evlab'=EventID==`eid'
7. local early07list "`early07list' `evlab'"
8. disp "fulllist `early07list'"
9. }
z20070731Jena_070731_petition
497 z20070731Jena070731_petition
fulllist z20070731Jena070731_petition
z20070731Jena_070731_protest
498 z20070731Jena070731_protest
fulllist z20070731Jena070731_petition z20070731Jena070731_protest
z20070628Jena_Belltrial07
508 z20070628JenaBelltrial07
fulllist z20070731Jena070731_petition z20070731Jena070731_protest z20070628JenaBelltrial07
z20070801Jena_internet
518 z20070801Jenainternet
fulllist z20070731Jena070731_petition z20070731Jena070731_protest z20070628JenaBelltrial07 z20070801Jenainternet
z20070101AlanBeanTrips_Jena07
4778 z20070101AlanBeanTripsJena07
fulllist z20070731Jena070731_petition z20070731Jena070731_protest z20070628JenaBelltrial07 z20070801Jenainternet z20070101AlanBeanTripsJena07
z20070815NAACP_JenaSix07
6141 z20070815NAACPJenaSix07
fulllist z20070731Jena070731_petition z20070731Jena070731_protest z20070628JenaBelltrial07 z20070801Jenainternet z20070101AlanBeanTripsJena07 z20070815NAACPJenaSix07
z20070809Jena6Sharpton_070809_Crthouse
_z20070809Jena6Sharpton_070809_Crthouse invalid name
r(198);
end of do-file
r(198);
Comment