Hi everyone,
I want to sum a variable and then assign its highest value +1 to an observation. The variable is called cluster and when I summarize it, max=2412. The observation is identified by the town_code 1997.
I tried to do this using (variable names are inclinated):
sum cluster
replace cluster= ( r(max) + 1 ) if town_code==1997
But nothing's changed. Is it even possible to assign r(max) to a variable in any way?
And can someone think of another way to automatically assign that observation (and others) with values of cluster that aren't assigned yet? (all these observations currently hold the value 1 in cluster).
Thanks a lot in advance,
Ben
Related Posts with Assigning a result from summarize to a variable
Offset() option in Poisson/negative binomial regressionHello everyone, I am working on count data and have the follow-up time in days. Do I need to log-tr…
How to edit or delete a "signature" that is auto-added to one's post?Many years ago I created a signature (e.g., name & a quotation) that was automatically added to …
Use Stata program with same name in different directoriesHi, I have a user-written program saved twice in my computer: once inside my system directory's usua…
Create a variable with an increasing value for different groupsDear all, I am using Stata version 14.2. I have a data set with groups of products and dates of we…
Merge (m:1) and data orderingHi all, please consider the following data example: Code: /*clear . input str6 id byte str4 loc …
Subscribe to:
Post Comments (Atom)
0 Response to Assigning a result from summarize to a variable
Post a Comment