Hello all,
I am working on exporting dataset subsets to separate Excel tabs, each named after property IDs from a real estate dataset. I've used a loop with levelsof to dynamically create sheet names based on property values and then export each property's data to its corresponding tab. However, I'm encountering an error that says "p invalid name r(198)" when executing the loop. Here's the relevant part of my code:
The error occurs during the loop, specifically when trying to use p as a part of the export excel command. Here is the error:
7. restore
8. }
Exporting property: 101
`p` invalid name
r(198);
Could anyone provide any insight on why this error is occurring and how to resolve it?
Any advice or alternative approaches would be greatly appreciated! Thank you so much!
I am working on exporting dataset subsets to separate Excel tabs, each named after property IDs from a real estate dataset. I've used a loop with levelsof to dynamically create sheet names based on property values and then export each property's data to its corresponding tab. However, I'm encountering an error that says "p invalid name r(198)" when executing the loop. Here's the relevant part of my code:
Code:
levelsof property, local(properties)
Code:
// Looping through properties & exporting to tabs foreach p of local properties { local sheet_name = string(`p', "%12.0g") // Converting num to str display "Exporting property: `sheet_name'" // debug check preserve keep if property == `p` export excel using "O:\monthly financial review\Submetering Data by Property and Month.xlsx", sheet("`sheet_name'") firstrow(variables) replace restore }
The error occurs during the loop, specifically when trying to use p as a part of the export excel command. Here is the error:
7. restore
8. }
Exporting property: 101
`p` invalid name
r(198);
Could anyone provide any insight on why this error is occurring and how to resolve it?
Any advice or alternative approaches would be greatly appreciated! Thank you so much!
Comment