<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>Statalist - Forums</title>
		<link>https://www.statalist.org/forums/</link>
		<description>vBulletin Forums</description>
		<language>en</language>
		<lastBuildDate>Fri, 07 Aug 2026 23:10:52 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>images/misc/rss.png</url>
			<title>Statalist - Forums</title>
			<link>https://www.statalist.org/forums/</link>
		</image>
		<item>
			<title>Getting confused in selecting Optimal Lag</title>
			<link>https://www.statalist.org/forums/forum/general-stata-discussion/general/1786971-getting-confused-in-selecting-optimal-lag</link>
			<pubDate>Fri, 07 Aug 2026 19:05:47 GMT</pubDate>
			<description>i am struggling in selecting optimal lag for Ardl model. my model is based on 33 observations . for this which command should i run for selecting...</description>
			<content:encoded><![CDATA[i am struggling in selecting optimal lag for Ardl model. my model is based on 33 observations . for this which command should i run for selecting optimal lag am getting confused Alot , i tried to take help from chatgpt but the provided ans are ambiguos.<br />
 therefore i would be glad if the precise command for lag selection is given to me keeping in mind of 33 observations of my model with 7 variables.best regards.]]></content:encoded>
			<category domain="https://www.statalist.org/forums/forum/general-stata-discussion/general">General</category>
			<dc:creator>Radoyan Hossain</dc:creator>
			<guid isPermaLink="true">https://www.statalist.org/forums/forum/general-stata-discussion/general/1786971-getting-confused-in-selecting-optimal-lag</guid>
		</item>
		<item>
			<title>Method of using interactive dummy in PVAR model</title>
			<link>https://www.statalist.org/forums/forum/general-stata-discussion/general/1786970-method-of-using-interactive-dummy-in-pvar-model</link>
			<pubDate>Fri, 07 Aug 2026 16:52:38 GMT</pubDate>
			<description>Dear Statalist members, 
 
I am attempting to incorporate an interactive dummy variable into a Panel VAR (PVAR) model estimated using GMM, and I...</description>
			<content:encoded><![CDATA[Dear Statalist members,<br />
<br />
I am attempting to incorporate an interactive dummy variable into a Panel VAR (PVAR) model estimated using GMM, and I would appreciate some guidance on whether my approach and Stata commands are appropriate.<br />
<br />
I consider the following equation:<br />
Y_it = Y_(it-1) + D_it X_(it-1) + u_it<br />
where (D_{it}) is a dummy variable constructed based on the change in (X). Specifically,<ul><li>(D_{it}=1) if (\Delta X_{it}&gt;0) (i.e., (X) increases), and</li>
<li>(D_{it}=0) if (\Delta X_{it}&lt;0) (i.e., (X) decreases).</li>
</ul>Thus, I intend (D_{it}X_{it-1}) to capture whether the effect of the lagged (X) on (Y) differs depending on whether (X) is increasing or decreasing.<br />
<br />
I estimate the model as a Panel VAR using GMM, treating both (Y) and (X) as endogenous. My Stata commands are:<br />
pvar y Dx1 Dx2 Dx3 Dx4, lags(1) instlags(1/6)<br />
pvargranger<br />
pvarirf, oirf mc(200) byoption(yrescale) porder(y Dx1 Dx2 Dx3 Dx4)<br />
My questions are:<ol class="decimal"><li>Is this specification an appropriate way to implement an interactive dummy variable in a PVAR framework?</li>
<li>Does the pvar command correctly estimate the model when the interaction term is constructed as (D_{it}X_{it-1}), while (Y) and (X) are treated as endogenous?</li>
<li>Are the pvarirf commands appropriate for obtaining impulse-response results for this specification?</li>
<li>If this approach is not appropriate, what would be the recommended way to incorporate and interpret an interactive dummy effect in a PVAR estimated using GMM?</li>
</ol>I would particularly appreciate guidance on whether the commands above actually estimate the intended interactive effect, or whether a different specification or estimation procedure is required.<br />
<br />
Thank you.]]></content:encoded>
			<category domain="https://www.statalist.org/forums/forum/general-stata-discussion/general">General</category>
			<dc:creator>Binita Dey</dc:creator>
			<guid isPermaLink="true">https://www.statalist.org/forums/forum/general-stata-discussion/general/1786970-method-of-using-interactive-dummy-in-pvar-model</guid>
		</item>
		<item>
			<title><![CDATA[sgmediation installation failed - &amp;quot;connection timed out&amp;quot; and &amp;quot;r(199)&amp;quot; error]]></title>
			<link>https://www.statalist.org/forums/forum/general-stata-discussion/general/1786960-sgmediation-installation-failed-connection-timed-out-and-r-199-error</link>
			<pubDate>Fri, 07 Aug 2026 10:56:10 GMT</pubDate>
			<description>Dear Statalist members, 
 
I am trying to run mediation analysis for my dissertation research using Stata 15/IC on Windows 7. I need to install...</description>
			<content:encoded><![CDATA[<span style="font-size:12px"><span style="font-family:tahoma">Dear Statalist members,<br />
<br />
I am trying to run mediation analysis for my dissertation research using Stata 15/IC on Windows 7. I need to install `sgmediation` to perform Sobel-Goodman mediation tests.<br />
<br />
I tried:<br />
<br />
ssc install sgmediation<br />
<br />
But I got the following error:<br />
<br />
&quot;connection timed out&quot; / &quot;package not found&quot;<br />
<br />
I also tried:<br />
<br />
net from <a href="http://fmwww.bc.edu/RePEc/bocode/s/" target="_blank">http://fmwww.bc.edu/RePEc/bocode/s/</a><br />
net install sgmediation<br />
<br />
Still the same issue.<br />
<br />
My internet connection is working fine. I can browse websites without problems.<br />
<br />
What I need:<br />
- I want to test whether Tax Reform (TREF) mediates the relationship between Leverage, Profitability, and Liquidity on Corporate Tax Planning (CETR).<br />
- I have 120 observations (12 firms × 10 years).<br />
<br />
When I tried SEM as an alternative:<br />
<br />
sem (CETR &lt;- Leverage TREF) (TREF &lt;- Leverage)<br />
<br />
Stata gave this error:<br />
<br />
&quot;model not identified; no paths from latent variable CETR to observed variables&quot; r(503)<br />
<br />
I typed &quot;estat teftects&quot; (which was a typo) and got &quot;r(321)&quot; error. I now know it should be &quot;estat teffects&quot;.<br />
<br />
My questions:<br />
1. How can I successfully install sgmediation?<br />
2. If sgmediation cannot be installed, how do I correctly specify the SEM model for mediation?<br />
3. Is there an alternative way to test mediation without sgmediation?<br />
<br />
What I have tried:<br />
- ssc install sgmediation<br />
- ssc install sgmediation, replace<br />
- net from <a href="http://fmwww.bc.edu/RePEc/bocode/s/" target="_blank">http://fmwww.bc.edu/RePEc/bocode/s/</a><br />
- net install sgmediation<br />
- Checking Stata's ado path<br />
<br />
Any advice would be greatly appreciated.<br />
<br />
Thank you,<br />
Hudu Zayyanu Ahmed<br />
Stata 15/IC, Windows 7</span></span>]]></content:encoded>
			<category domain="https://www.statalist.org/forums/forum/general-stata-discussion/general">General</category>
			<dc:creator>Ahmed Zayyanu Hudu</dc:creator>
			<guid isPermaLink="true">https://www.statalist.org/forums/forum/general-stata-discussion/general/1786960-sgmediation-installation-failed-connection-timed-out-and-r-199-error</guid>
		</item>
		<item>
			<title>panel dataset</title>
			<link>https://www.statalist.org/forums/forum/general-stata-discussion/general/1786953-panel-dataset</link>
			<pubDate>Thu, 06 Aug 2026 21:58:28 GMT</pubDate>
			<description>I am looking for a good panel dataset to explain GEE. McCuloloch, Searle and Neuhaus mention a dataset modelling alcohol consumption and low birth...</description>
			<content:encoded>I am looking for a good panel dataset to explain GEE. McCuloloch, Searle and Neuhaus mention a dataset modelling alcohol consumption and low birth weight. There is the stata dataset by Hosemer and Lemeshow called lbw but it is not panel data. Is anyone aware of a publically accessible teaching dataset along these lines?</content:encoded>
			<category domain="https://www.statalist.org/forums/forum/general-stata-discussion/general">General</category>
			<dc:creator>Matt Piercy</dc:creator>
			<guid isPermaLink="true">https://www.statalist.org/forums/forum/general-stata-discussion/general/1786953-panel-dataset</guid>
		</item>
		<item>
			<title>Model for dataset with a very small number of incidents.</title>
			<link>https://www.statalist.org/forums/forum/general-stata-discussion/general/1786945-model-for-dataset-with-a-very-small-number-of-incidents</link>
			<pubDate>Wed, 05 Aug 2026 20:36:56 GMT</pubDate>
			<description>Hello, I was wondering if anyone could provide advice on model selection for my dataset. I have data from a longitudinal survey with five waves: one...</description>
			<content:encoded><![CDATA[Hello, I was wondering if anyone could provide advice on model selection for my dataset. I have data from a longitudinal survey with five waves: one baseline wave and four follow-up waves. My goal is to model post-baseline home eviction rates.<br />
<br />
The challenge is that only 18 participants reported experiencing at least one home eviction during follow-up. I use the number of home evictions as the outcome variable and the total number of post-baseline waves completed as the exposure (offset) in a Poisson regression model, along with the covariates listed below.<br />
<br />
My concern is that the number of non-zero outcomes is so small that the model appears to be overfit, resulting in very wide confidence intervals. Could anyone recommend an alternative modeling approach for count data with such a small number of events, or suggest strategies for handling this type of sparse outcome?<br />
<br />
<br />
<br />
<br />
c.ppage ///<br />
i.biosex ///<br />
i.race_alt ///<br />
i.education ///<br />
i.region ///<br />
i.income ///<br />
i.Personal_debt ///<br />
c.sf8pcs ///<br />
c.sf8mcs ///<br />
i.asud ///<br />
i.asmi ///<br />
i.housetype_alt ///<br />
i.employment, ///<br />
exposure(total_years) ///<br />
<br />
<br />
<br />
<br />

<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code">


 tab total_years

  Number of |
      waves |
 present in |
 the survey |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |         91       10.87       10.87
          2 |        110       13.14       24.01
          3 |        113       13.50       37.51
          4 |        523       62.49      100.00
------------+-----------------------------------
      Total |        837      100.00

. tab any_eviction_count

      Total |
  number of |
  evictions |
       from |
Year01-Year |
         04 |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        819       97.85       97.85
          1 |         13        1.55       99.40
          2 |          1        0.12       99.52
          3 |          2        0.24       99.76
          4 |          2        0.24      100.00
------------+-----------------------------------
      Total |        837      100.00</pre>
</div><br />
<br />
<br />
 ]]></content:encoded>
			<category domain="https://www.statalist.org/forums/forum/general-stata-discussion/general">General</category>
			<dc:creator>Luis Mijares Castaneda</dc:creator>
			<guid isPermaLink="true">https://www.statalist.org/forums/forum/general-stata-discussion/general/1786945-model-for-dataset-with-a-very-small-number-of-incidents</guid>
		</item>
		<item>
			<title>Question about mixed-effects models after linear interpolation of longitudinal data</title>
			<link>https://www.statalist.org/forums/forum/general-stata-discussion/general/1786920-question-about-mixed-effects-models-after-linear-interpolation-of-longitudinal-data</link>
			<pubDate>Tue, 04 Aug 2026 12:00:06 GMT</pubDate>
			<description>Dear all,  
I would appreciate your advice regarding the appropriate analysis of a longitudinal dataset in Stata. 
 
I have a cohort of 221 patients...</description>
			<content:encoded><![CDATA[Dear all, <br />
I would appreciate your advice regarding the appropriate analysis of a longitudinal dataset in Stata.<br />
<br />
I have a cohort of 221 patients with repeated DXA Z-score measurements obtained at irregular follow-up times, resulting in 2,373 observed Z-score measurements. To standardize follow-up at annual intervals (as required for a publication), I linearly interpolated Z-scores between consecutive observed measurements, producing an anniversary-year dataset with 4,498 observations from 197 patients. Patients with only one observed measurement could not be interpolated and were therefore excluded from the anniversary-year dataset.<br />
<br />
I am fitting the following mixed-effects model:<br />
<br />
mixed z_score c.anniv_year##(i.z_sitespine1hip2radius3 i.gender1female i.splenectomy1yes i.n370s_homozygous1yes i.eversmoked i.typetype11type30 c.interval_symptom_tx c.zimran_score c.ert_date1 c.ageatthestartoftreatment c.anniv_bmi c.vitamind_anniv ib2.erttype1alglucerase2velagluceras c.ukg i.bisphosphonatesanniv_year0no1yes) || subject_id: c.anniv_year, covariance(unstructured) reml dfmethod(kroger)<br />
<br />
My question concerns statistical inference. Since many of the Z-scores were created by deterministic linear interpolation rather than being directly observed, I am concerned that treating all anniversary-year observations as regular measurements may underestimate uncertainty.<br />
<br />
I initially wondered whether mi estimate should be used, but I understand that mi estimate is intended for multiple imputation rather than deterministic interpolation<br />
<br />
Could you please advise:<ol class="decimal"><li>Is there any recommended way in Stata to account for the additional uncertainty introduced by deterministic linear interpolation when fitting a mixed-effects model?</li>
<li>Is using reml dfmethod(kroger) considered sufficient for  this setting, or is there another recommended approach?</li>
<li>Should I I fit the mixed model using only the original observed measurements and compare it with the interpolated mixed model?</li>
</ol>Any guidance or references to recommended practice would be greatly appreciated.<br />
<br />
Thank you very much for your time and assistance<br />
<br />
Best, <br />
Oana <br />
 ]]></content:encoded>
			<category domain="https://www.statalist.org/forums/forum/general-stata-discussion/general">General</category>
			<dc:creator>Oana Vaida</dc:creator>
			<guid isPermaLink="true">https://www.statalist.org/forums/forum/general-stata-discussion/general/1786920-question-about-mixed-effects-models-after-linear-interpolation-of-longitudinal-data</guid>
		</item>
		<item>
			<title>New commands on SSC: atip_reglas/atip_score/atip_volcano/atip_mahal (outlier detection) and mmd_2s (distributional comparison)</title>
			<link>https://www.statalist.org/forums/forum/general-stata-discussion/general/1786913-new-commands-on-ssc-atip_reglas-atip_score-atip_volcano-atip_mahal-outlier-detection-and-mmd_2s-distributional-comparison</link>
			<pubDate>Mon, 03 Aug 2026 20:01:46 GMT</pubDate>
			<description><![CDATA[Dear Statalist, 
I would like to announce six new commands now available on SSC, developed while building a data-quality pipeline for Peru's National...]]></description>
			<content:encoded><![CDATA[Dear Statalist,<br />
I would like to announce six new commands now available on SSC, developed while building a data-quality pipeline for Peru's National Agricultural Survey (ENA) at INEI. All are validated by simulation (results and methodology documented in each help file), and none require any commercial license beyond base Stata.<br />
Outlier detection suite (four commands, designed to work together):<br />
- atip_reglas: flags outliers within groups using an ensemble of five classic rules (mean+/-3SD, mean+/-2SD, z-score, Tukey IQR, univariate Mahalanobis). Uses median/MAD instead of mean/SD by default, which is far more robust under contamination -- simulation shows recall rising from 27.4% to 95.5% at 20% contamination.<br />
- atip_score: generalizes atip_reglas into two separate continuous axes (evidence: how many rules fired; magnitude: how far the value is), instead of a single binary flag -- useful for selective-editing style triage rather than a hard cutoff.<br />
- atip_volcano: volcano-style plot (magnitude vs. evidence) of atip_score output, without inventing a formal p-value for what are heuristic rules.<br />
- atip_mahal: genuine multivariate outlier detection (2+ variables) via Mahalanobis distance, using the Minimum Covariance Determinant estimator (Rousseeuw and Van Driessen 1999) by default -- classical covariance collapses under masking (multiple simultaneous outliers), MCD does not. Simulation: 100% recall at 20% contamination with MCD vs. 0% with the classical estimator. Includes an optional tolerance-ellipse plot (k=2) that can overlay both classical and MCD ellipses to visualize masking directly.<br />
Distributional comparison:<br />
- mmd_2s: two-sample test based on Maximum Mean Discrepancy (RBF kernel), for comparing whether two samples come from the same distribution -- more general than a t-test (catches differences in variance/shape, not just location) and complementary to a Kolmogorov-Smirnov test. Weighting is fully optional via Stata's native [pweight/aweight/iweight] syntax.<br />
Install any of them with:<br />

<div class="bbcode_container">
	<div class="bbcode_description">HTML Code:</div>
	<pre class="bbcode_code"> ssc install atip_reglas</pre>
</div>
<div class="bbcode_container">
	<div class="bbcode_description">HTML Code:</div>
	<pre class="bbcode_code"> ssc install atip_score</pre>
</div>
<div class="bbcode_container">
	<div class="bbcode_description">HTML Code:</div>
	<pre class="bbcode_code"> ssc install atip_volcano</pre>
</div>
<div class="bbcode_container">
	<div class="bbcode_description">HTML Code:</div>
	<pre class="bbcode_code"> ssc install atip_mahal</pre>
</div>
<div class="bbcode_container">
	<div class="bbcode_description">HTML Code:</div>
	<pre class="bbcode_code"> ssc install mmd_2s</pre>
</div>All help files include real-data examples (sysuse auto/nlsw88) plus a companion command, SRIINEI, for downloading public microdata directly from Peru's official statistics portal (also on SSC, ssc install sriinei) -- useful if anyone wants to reproduce the real-data examples themselves.<br />
Comments, bug reports, and suggestions welcome.<br />
Best regards,<br />
Andres Talavera Cuya<br />
<a href="mailto:atalaveracuya@gmail.com">atalaveracuya@gmail.com</a>]]></content:encoded>
			<category domain="https://www.statalist.org/forums/forum/general-stata-discussion/general">General</category>
			<dc:creator>Andrés Lahur Talavera Cuya</dc:creator>
			<guid isPermaLink="true">https://www.statalist.org/forums/forum/general-stata-discussion/general/1786913-new-commands-on-ssc-atip_reglas-atip_score-atip_volcano-atip_mahal-outlier-detection-and-mmd_2s-distributional-comparison</guid>
		</item>
		<item>
			<title>SSC Archive</title>
			<link>https://www.statalist.org/forums/forum/general-stata-discussion/general/1786902-ssc-archive</link>
			<pubDate>Sun, 02 Aug 2026 17:21:53 GMT</pubDate>
			<description>Details of SSC Archive downloads for July 2026 are now available via sec hot. As a reminder, you can access download statistics for a particular...</description>
			<content:encoded><![CDATA[Details of SSC Archive downloads for July 2026 are now available via sec hot. As a reminder, you can access download statistics for a particular author's packages with sec hot, author(last name). That can be combined with the n(#) option to view more than 10 packages.<br />
<br />
Rankings for the last three months for 1,555 authors are available at <a href="http://repec.org/docs/sscAuthors.html" target="_blank">http://repec.org/docs/sscAuthors.html</a><br />
<br />
Updates to the SSC Archive will be suspended August 5-19 during travels.<br />
 ]]></content:encoded>
			<category domain="https://www.statalist.org/forums/forum/general-stata-discussion/general">General</category>
			<dc:creator>KitBaum</dc:creator>
			<guid isPermaLink="true">https://www.statalist.org/forums/forum/general-stata-discussion/general/1786902-ssc-archive</guid>
		</item>
		<item>
			<title>SSC Archive, July 2026</title>
			<link>https://www.statalist.org/forums/forum/general-stata-discussion/general/1786897-ssc-archive-july-2026</link>
			<pubDate>Sat, 01 Aug 2026 14:49:58 GMT</pubDate>
			<description>With wider use of AI translation tools, an amazing 64 packages were added to the SSC Archive in July, and 46 existing packages were revised. The...</description>
			<content:encoded>With wider use of AI translation tools, an amazing 64 packages were added to the SSC Archive in July, and 46 existing packages were revised. The details are available at ssc whatsnew.  Download statistics have also increased; results for July will be available in a day or so.</content:encoded>
			<category domain="https://www.statalist.org/forums/forum/general-stata-discussion/general">General</category>
			<dc:creator>KitBaum</dc:creator>
			<guid isPermaLink="true">https://www.statalist.org/forums/forum/general-stata-discussion/general/1786897-ssc-archive-july-2026</guid>
		</item>
		<item>
			<title><![CDATA[Boot CV for 'fbaardl' under &amp;quot;aardl&amp;quot; package]]></title>
			<link>https://www.statalist.org/forums/forum/general-stata-discussion/general/1786896-boot-cv-for-fbaardl-under-aardl-package</link>
			<pubDate>Sat, 01 Aug 2026 10:08:43 GMT</pubDate>
			<description><![CDATA[It would have been nice if the Boot CV for 1% and 10% are also given in addition to the 5% level (which is available) when we use the 'fbaardl'...]]></description>
			<content:encoded><![CDATA[It would have been nice if the Boot CV for 1% and 10% are also given in addition to the 5% level (which is available) when we use the 'fbaardl' option under the &quot;aardl&quot; package. This is necessary for reporting in the research paper.]]></content:encoded>
			<category domain="https://www.statalist.org/forums/forum/general-stata-discussion/general">General</category>
			<dc:creator>Abhijit Lahiri</dc:creator>
			<guid isPermaLink="true">https://www.statalist.org/forums/forum/general-stata-discussion/general/1786896-boot-cv-for-fbaardl-under-aardl-package</guid>
		</item>
		<item>
			<title>String variables with value labels!!</title>
			<link>https://www.statalist.org/forums/forum/general-stata-discussion/general/1786891-string-variables-with-value-labels</link>
			<pubDate>Fri, 31 Jul 2026 20:59:35 GMT</pubDate>
			<description>As far as I understand string variables cannot have value labels. However, I have received a dataset with string variables which shows (output of...</description>
			<content:encoded><![CDATA[As far as I understand string variables cannot have value labels. However, I have received a dataset with string variables which shows (output of -describe- command) that the string variables have value labels attached to them. Moreover, the value labels have two or more different labels (texts) attached to the same value 0 (while the variables have no zero values). Could anyone share any thought about what might be going on here? Or have any of you encountered this problem ever? I am sharing my code and its output below (I cannot even understand how to give a data example in this context as I do not know how to create string variables with value labels, so pardon me.) Note that the problem remains the same even if I save the data in the newer dta format 118.<br />
<br />

<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code">. use &quot;D:\L02_Demographic_particulars.dta&quot; 

. version
version 19.5

. dtaversion &quot;D:\L02_Demographic_particulars.dta&quot;
  (file &quot;D:\L02_Demographic_particulars.dta&quot; is .dta-format 115 from Stata 12)

. describe Sector Gender

Variable      Storage   Display    Value
    name         type    format    label      Variable label
--------------------------------------------------------------------------------
Sector          str1    %-9s       Sector0    Sector
Gender          str1    %-9s       Gender2    Gender


. label list Sector0 Gender2
Sector0:
           0 urban
           0 rural
Gender2:
           0 Female
           0 transgender
           0 Male

. tab Sector

     Sector |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |    292,208       62.63       62.63
          2 |    174,319       37.37      100.00
------------+-----------------------------------
      Total |    466,527      100.00

. tab Gender

     Gender |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |    240,556       51.56       51.56
          2 |    225,897       48.42       99.98
          3 |         74        0.02      100.00
------------+-----------------------------------
      Total |    466,527      100.00</pre>
</div><br />
<br />
<br />
<br />
 ]]></content:encoded>
			<category domain="https://www.statalist.org/forums/forum/general-stata-discussion/general">General</category>
			<dc:creator>Krishanu Karmakar</dc:creator>
			<guid isPermaLink="true">https://www.statalist.org/forums/forum/general-stata-discussion/general/1786891-string-variables-with-value-labels</guid>
		</item>
		<item>
			<title>-reshapehelper- on SSC</title>
			<link>https://www.statalist.org/forums/forum/general-stata-discussion/general/1786886-reshapehelper-on-ssc</link>
			<pubDate>Fri, 31 Jul 2026 14:37:16 GMT</pubDate>
			<description><![CDATA[-reshape- is the command everyone second-guesses or runs to the help file for support (or maybe it's just me) 
 
-reshapehelper- helps with that....]]></description>
			<content:encoded><![CDATA[-reshape- is the command everyone second-guesses or runs to the help file for support (or maybe it's just me)<br />
<br />
-reshapehelper- helps with that. It's a command that works out the reshape for you: it reads your variable names, figures out the wide-or-long data structure, and dry-runs the command on a subset copy of your data.<br />
You get back exact, copy/paste-ready -reshape- syntax (stored in `r(cmd)') with a pass/fail verdict. **No LLMs involved ... no, not an April Fool's prank**<br />
<br />
• Detects i and j automatically (xtset / tsset / svyset aware) and most data layouts (e.g., long, wide (or even triply-wide) data)<br />
• Tests the reshape before you run it, identifies duplicates ... avoids most r(198) surprises<br />
• Hands you working syntax, not a guess or a panic-run to the .sthlp file<br />
<br />
Thanks to <a href="https://www.statalist.org/forums/member/9-kitbaum" class="b-bbcode-user js-bbcode-user" data-userid="9">KitBaum</a> it's on SSC via:<br />
<br />

<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code">ssc install reshapehelper</pre>
</div>Some worked examples below. To pressure test this I dug through reshape questions from this community over the past few years and I tried to anticipate possible data shapes or conditions that might break -reshapehelper-. Where the program cannot recursively act to detect the structure or variable patterns (even with your help) it suggests some next steps to diagnose the problem in the output.<br />
<br />
More examples in the help file:<br />
<br />

<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code">* ---------------------------------------------------------------------------
* T1. Classic wide -&gt; long, numeric suffixes ([D] reshape Example 1)
* ---------------------------------------------------------------------------
clear
input id sex inc80 inc81 inc82
1 0 5000 5500 6000
2 1 2000 2200 3300
3 0 3000 2000 1000
end
reshapehelper
assert &quot;`r(status)'&quot;    == &quot;ok&quot;
assert &quot;`r(direction)'&quot; == &quot;wide2long&quot;
assert r(tested)        == 1
assert strpos(`&quot;`r(cmd)'&quot;', &quot;reshape long inc, i(id) j(year)&quot;) &gt; 0
assert `&quot;$reshapehelper_cmd&quot;' == `&quot;`r(cmd)'&quot;'
assert _N == 3 &amp; c(k) == 5          // data untouched

* ---------------------------------------------------------------------------
* T2. Two stubs at once: inc AND ue ([D] reshape Example 1, full)
* ---------------------------------------------------------------------------
clear
input id sex inc80 inc81 inc82 ue80 ue81 ue82
1 0 5000 5500 6000 0 1 0
2 1 2000 2200 3300 1 0 0
3 0 3000 2000 1000 0 0 1
end
reshapehelper
assert &quot;`r(status)'&quot; == &quot;ok&quot;
assert r(tested)     == 1
assert strpos(`&quot;`r(cmd)'&quot;', &quot;reshape long inc ue, i(id) j(year)&quot;) &gt; 0

* ---------------------------------------------------------------------------
* T3. Classic long -&gt; wide ([D] reshape Example 1 reversed)
* ---------------------------------------------------------------------------
clear
input id year sex inc ue
1 80 0 5000 0
1 81 0 5500 1
1 82 0 6000 0
2 80 1 2000 1
2 81 1 2200 0
2 82 1 3300 0
3 80 0 3000 0
3 81 0 2000 0
3 82 0 1000 1
end
reshapehelper, to(wide)
assert &quot;`r(status)'&quot;    == &quot;ok&quot;
assert &quot;`r(direction)'&quot; == &quot;long2wide&quot;
assert r(tested)        == 1
assert strpos(`&quot;`r(cmd)'&quot;', &quot;reshape wide inc ue, i(id) j(year)&quot;) &gt; 0
assert _N == 9 &amp; c(k) == 5

* ---------------------------------------------------------------------------
* T4. String suffixes after an underscore (sysuse bpwide)
* ---------------------------------------------------------------------------
sysuse bpwide, clear
reshapehelper
assert &quot;`r(status)'&quot; == &quot;ok&quot;
assert r(tested)     == 1
assert strpos(`&quot;`r(cmd)'&quot;', &quot;reshape long bp_, i(patient) j(period) string&quot;) &gt; 0

* ---------------------------------------------------------------------------
* T5. @ mid-name stubs beside plain stubs ([D] reshape Example 7: inc@r + ue)
* ---------------------------------------------------------------------------
clear
input id sex inc80r inc81r inc82r ue80 ue81 ue82
1 0 5000 5500 6000 0 1 0
2 1 2000 2200 3300 1 0 0
3 0 3000 2000 1000 0 0 1
end
reshapehelper
assert &quot;`r(status)'&quot; == &quot;ok&quot;
assert r(tested)     == 1
assert strpos(`&quot;`r(cmd)'&quot;', &quot;inc@r&quot;) &gt; 0
assert strpos(`&quot;`r(cmd)'&quot;', &quot;ue&quot;) &gt; 0
assert strpos(`&quot;`r(cmd)'&quot;', &quot;j(year)&quot;) &gt; 0

* ---------------------------------------------------------------------------
* T6. Unbalanced stubs: ue81 does not exist ([D] reshape Example 6)
* ---------------------------------------------------------------------------
clear
input id sex inc80 inc81 inc82 ue80 ue82
1 0 5000 5500 6000 0 0
2 1 2000 2200 3300 1 0
3 0 3000 2000 1000 0 1
end
reshapehelper
assert &quot;`r(status)'&quot; == &quot;ok&quot;
assert r(tested)     == 1
assert strpos(`&quot;`r(cmd)'&quot;', &quot;reshape long inc ue, i(id) j(year)&quot;) &gt; 0
assert strpos(`&quot;`r(note)'&quot;', &quot;unbalanced&quot;) &gt; 0

* ---------------------------------------------------------------------------
* T7. The inc2 trap: a stray same-stub variable ([D] reshape, j() values).
*     The dry run PASSES (reshape happily builds a j=2 group), so the
*     mixed-width caution is the safety net.
* ---------------------------------------------------------------------------
clear
input id sex inc80 inc81 inc82 inc2
1 0 5000 5500 6000 1
2 1 2000 2200 3300 0
3 0 3000 2000 1000 1
end
reshapehelper
assert &quot;`r(status)'&quot; == &quot;ok&quot;
assert r(tested)     == 1
assert strpos(`&quot;`r(caution)'&quot;', &quot;widths differ&quot;) &gt; 0
assert strpos(`&quot;`r(caution)'&quot;', &quot;restrict j&quot;) &gt; 0

* ---------------------------------------------------------------------------
* T8. Inconsistent stub names: inc80 / income81 / incm82 (UVA + Stata FAQ).
*     No family forms, so the helper must say so and coach a rename.
* ---------------------------------------------------------------------------
clear
input id sex inc80 income81 incm82
1 0 5000 5500 6000
2 1 2000 2200 3300
3 0 3000 2000 1000
end
reshapehelper
assert &quot;`r(status)'&quot; == &quot;needinfo&quot;
assert `&quot;`r(cmd)'&quot;' == &quot;&quot;

* ---------------------------------------------------------------------------
* T9. String j containing spaces (Statalist r(111) thread): forced j(state)
*     must trigger the pre-clean line, the string option, and a passing test
* ---------------------------------------------------------------------------
clear
input year str12 state pop
2020 &quot;New York&quot; 20.2
2020 &quot;Texas&quot; 29.1
2021 &quot;New York&quot; 19.8
2021 &quot;Texas&quot; 29.5
end
reshapehelper, to(wide) j(state)
assert &quot;`r(status)'&quot; == &quot;ok&quot;
assert r(tested)     == 1
assert strpos(`&quot;`r(cmd)'&quot;', &quot;j(state) string&quot;) &gt; 0
assert strpos(`&quot;`r(preclean)'&quot;', &quot;subinstr&quot;) &gt; 0
assert _N == 4 &amp; c(k) == 3          // caller's data untouched (incl. spaces)
assert strpos(state[1], &quot; &quot;) &gt; 0

* ---------------------------------------------------------------------------
* T10. Prefix-as-j: qld_p nsw_p vic_p (Statalist &quot;no xij variables found&quot;)
* ---------------------------------------------------------------------------
clear
input year qld_p nsw_p vic_p
2018 4.9 7.9 6.4
2019 5.0 8.0 6.5
2020 5.1 8.1 6.6
end
reshapehelper
assert &quot;`r(status)'&quot; == &quot;ok&quot;
assert r(tested)     == 1
assert strpos(`&quot;`r(cmd)'&quot;', &quot;@_p&quot;) &gt; 0
assert strpos(`&quot;`r(cmd)'&quot;', &quot;string&quot;) &gt; 0

* ---------------------------------------------------------------------------
* T11. Duplicate (i, j) pairs block reshape wide (Statalist / manual Ex. 3):
*      the helper must diagnose, count, and hand back the remedy menu
* ---------------------------------------------------------------------------
clear
input id year inc
1 2019 45000
1 2020 47000
2 2019 32000
2 2019 32000
2 2020 33500
end
reshapehelper, to(wide)
assert &quot;`r(status)'&quot; == &quot;needinfo&quot;
assert strpos(`&quot;`r(diagnosis)'&quot;', &quot;duplicates report&quot;) &gt; 0
assert strpos(`&quot;`r(diagnosis)'&quot;', &quot;collapse&quot;) &gt; 0
assert strpos(`&quot;`r(diagnosis)'&quot;', &quot;concat&quot;) &gt; 0

* ---------------------------------------------------------------------------
* T12. Two crossed factors (Statalist animal/level/delay): the helper finds a
*      compound i and widens ONE factor, and its note points to the rest
* ---------------------------------------------------------------------------
clear
input animal s1level s1s2delay s2peakvalue
1 0 50 12.1
1 0 100 13.4
1 0 200 15.2
1 1 50 18.3
1 1 100 19.9
1 1 200 22.4
2 0 50 11.8
2 0 100 12.9
2 0 200 14.7
2 1 50 17.5
2 1 100 19.2
2 1 200 21.8
end
reshapehelper, to(wide)
assert &quot;`r(status)'&quot; == &quot;ok&quot;
assert r(tested)     == 1
assert strpos(`&quot;`r(cmd)'&quot;', &quot;reshape wide s2peakvalue&quot;) &gt; 0
assert strpos(`&quot;`r(note)'&quot;', &quot;concat&quot;) &gt; 0

* ---------------------------------------------------------------------------
* T13. Doubly wide (UCLA FAQ): two digit runs in the names -&gt; two chained
*      reshapes, both dry-run tested
* ---------------------------------------------------------------------------
clear
input famid ht_k1_t1 ht_k1_t2 ht_k2_t1 ht_k2_t2
1 3.1 3.6 4.0 4.4
2 3.3 3.8 4.1 4.6
3 3.0 3.5 3.9 4.3
end
reshapehelper
assert &quot;`r(status)'&quot;    == &quot;ok&quot;
assert &quot;`r(direction)'&quot; == &quot;doubly&quot;
assert r(tested)        == 1
assert `&quot;`r(cmd2)'&quot;' != &quot;&quot;
assert strpos(`&quot;`r(cmd)'&quot;',  &quot;reshape long ht_k1_t ht_k2_t, i(famid)&quot;) &gt; 0
assert strpos(`&quot;`r(cmd2)'&quot;', &quot;reshape long ht_k@_t, i(famid&quot;) &gt; 0
assert _N == 3 &amp; c(k) == 5

* ---------------------------------------------------------------------------
* T14. Long-long to wide-wide, step one ([D] reshape second-level nesting):
*      compound i() found, low-cardinality factor left in i() flagged
* ---------------------------------------------------------------------------
clear
input hid str1 sex year inc
1 &quot;f&quot; 90 3200
1 &quot;f&quot; 91 4700
1 &quot;m&quot; 90 4500
1 &quot;m&quot; 91 4600
2 &quot;f&quot; 90 3600
2 &quot;f&quot; 91 3800
2 &quot;m&quot; 90 5100
2 &quot;m&quot; 91 5300
end
reshapehelper, to(wide)
assert &quot;`r(status)'&quot; == &quot;ok&quot;
assert r(tested)     == 1
assert strpos(`&quot;`r(cmd)'&quot;', &quot;reshape wide inc&quot;) &gt; 0
assert `&quot;`r(note)'&quot;' != &quot;&quot;

* ---------------------------------------------------------------------------
* T15. Already-long tidy panel, no to(): the helper reads it as long and
*      offers the wide command
* ---------------------------------------------------------------------------
clear
input id year inc
1 80 5000
1 81 5500
1 82 6000
2 80 2000
2 81 2200
2 82 3300
end
reshapehelper
assert &quot;`r(status)'&quot;    == &quot;ok&quot;
assert &quot;`r(direction)'&quot; == &quot;long2wide&quot;
assert r(tested)        == 1

* ---------------------------------------------------------------------------
* T16. Transpose, not reshape (Statalist xpose thread): metrics as rows
* ---------------------------------------------------------------------------
clear
input str12 metric alpha beta gamma
&quot;n&quot;       100 200 150
&quot;mean&quot;    52.1 48.9 50.3
&quot;missing&quot; 3 7 5
end
reshapehelper
assert &quot;`r(status)'&quot; == &quot;needinfo&quot;
assert r(xpose) == 1

* ---------------------------------------------------------------------------
* T17. Wide-long panel honoring xtset: county-year rows with sector columns;
*      i() must include the existing time variable
* ---------------------------------------------------------------------------
clear
input county year emp_manuf emp_retail emp_gov
1 2019 120 340 210
1 2020 115 330 215
2 2019  80 210 150
2 2020  78 220 155
3 2019  60 190 120
3 2020  61 200 118
end
xtset county year
reshapehelper
assert &quot;`r(status)'&quot; == &quot;ok&quot;
assert r(tested)     == 1
assert strpos(`&quot;`r(cmd)'&quot;', &quot;reshape long emp_, i(county year)&quot;) &gt; 0
assert strpos(`&quot;`r(cmd)'&quot;', &quot;string&quot;) &gt; 0
assert strpos(`&quot;`r(note)'&quot;', &quot;SECOND long dimension&quot;) &gt; 0

* ---------------------------------------------------------------------------
* T18. User-assisted bare string suffixes ([D] reshape Example 8: incm/incf):
*      stubs()+i()+j() supplied; the dry-run engine discovers the string
*      option by iterating on reshape's own r(498)
* ---------------------------------------------------------------------------
clear
input id kids incm incf
1 0 5000 5500
2 1 2000 2200
3 2 3000 2000
end
reshapehelper, to(long) stubs(inc) i(id) j(sex)
assert &quot;`r(status)'&quot; == &quot;ok&quot;
assert r(tested)     == 1
assert strpos(`&quot;`r(cmd)'&quot;', &quot;reshape long inc, i(id) j(sex) string&quot;) &gt; 0

* ---------------------------------------------------------------------------
* T19. Guardrails: shorthand tokens, bad options, empty data
* ---------------------------------------------------------------------------
sysuse bpwide, clear
reshapehelper long                    // bare-token shorthand for to(long)
assert &quot;`r(status)'&quot; == &quot;ok&quot;
capture reshapehelper, to(sideways)
assert _rc == 198
capture reshapehelper, sample(3)
assert _rc == 198
clear
capture reshapehelper
assert _rc == 2000

* ---------------------------------------------------------------------------
* T20. The SMCL suggestion file exists and holds the unwrapped command
* ---------------------------------------------------------------------------
clear
input id inc80 inc81
1 5000 5500
2 2000 2200
end
tempfile junk
reshapehelper, smcl(&quot;scratch_suggestion.smcl&quot;) replace
assert &quot;`r(status)'&quot; == &quot;ok&quot;
confirm file &quot;scratch_suggestion.smcl&quot;
file open fh using &quot;scratch_suggestion.smcl&quot;, read text
local found 0
file read fh line
while r(eof) == 0 {
    if strpos(`&quot;`macval(line)'&quot;', &quot;reshape long inc, i(id) j(year)&quot;) local found 1
    file read fh line
}
file close fh
assert `found' == 1
erase &quot;scratch_suggestion.smcl&quot;

* ---------------------------------------------------------------------------
* T21. Edge sweep: hostile small/weird data must never crash, never touch
*      the data, and never leave a stale global
* ---------------------------------------------------------------------------
* (a) one observation, one variable -&gt; graceful checklist
clear
set obs 1
gen x = 1
reshapehelper
assert inlist(&quot;`r(status)'&quot;, &quot;needinfo&quot;, &quot;ok&quot;)
assert _N == 1 &amp; c(k) == 1

* (b) all-string dataset -&gt; graceful
clear
input str5 a str5 b
&quot;x&quot; &quot;y&quot;
&quot;z&quot; &quot;w&quot;
end
reshapehelper
assert inlist(&quot;`r(status)'&quot;, &quot;needinfo&quot;, &quot;ok&quot;)
assert _N == 2 &amp; c(k) == 2

* (c) strL beside wide stubs -&gt; still suggests, strL skipped in probes
clear
input id inc80 inc81
1 5000 5500
2 2000 2200
end
gen strL comment = &quot;free text &quot; + string(id)
reshapehelper
assert &quot;`r(status)'&quot; == &quot;ok&quot;
assert r(tested) == 1
assert strpos(`&quot;`r(cmd)'&quot;', &quot;reshape long inc, i(id)&quot;) &gt; 0
assert c(k) == 4

* (d) a variable named year already exists beside inc80-inc82: the proposed
*     j must dodge the collision and the dry run must still pass
clear
input id year inc80 inc81 inc82
1 1999 5000 5500 6000
2 1999 2000 2200 3300
end
reshapehelper
assert &quot;`r(status)'&quot; == &quot;ok&quot;
assert r(tested) == 1
assert strpos(`&quot;`r(cmd)'&quot;', &quot;j(year)&quot;) == 0

* (e) bare stub variable v beside v1-v3 (reshape r(110) territory): composed
*     but honestly reported as blocked after the dry run cannot fix it
clear
input id v v1 v2 v3
1 9 10 11 12
2 8 20 21 22
end
reshapehelper
assert inlist(&quot;`r(status)'&quot;, &quot;blocked&quot;, &quot;needinfo&quot;)
assert _N == 2 &amp; c(k) == 5

* (f) widening would build names longer than 32 chars: caution + honest fail
clear
input id year abcdefghijklmnopqrstuvwxyzabcde
1 2018 1.1
1 2019 1.2
2 2018 2.1
2 2019 2.2
end
reshapehelper, to(wide)
assert inlist(&quot;`r(status)'&quot;, &quot;blocked&quot;, &quot;ok&quot;)
if &quot;`r(status)'&quot; == &quot;blocked&quot; assert `&quot;`r(caution)'&quot;' != &quot;&quot;

* (g) missing values in the j candidate -&gt; no crash, data untouched
clear
input id year x
1 2018 1
1 2019 2
1    . 3
2 2018 4
2 2019 5
end
reshapehelper, to(wide)
assert inlist(&quot;`r(status)'&quot;, &quot;ok&quot;, &quot;blocked&quot;, &quot;needinfo&quot;)
assert _N == 5 &amp; c(k) == 3

* (h) an all-missing variable beside normal stubs -&gt; still ok
clear
input id inc80 inc81
1 5000 5500
2 2000 2200
end
gen ghost = .
reshapehelper
assert &quot;`r(status)'&quot; == &quot;ok&quot;

* (i) mixed-case stubs Inc_80/Inc_81: case preserved in the suggestion
clear
input id Inc_80 Inc_81
1 5000 5500
2 2000 2200
end
reshapehelper
assert &quot;`r(status)'&quot; == &quot;ok&quot;
assert strpos(`&quot;`r(cmd)'&quot;', &quot;Inc_&quot;) &gt; 0

* (j) value-labeled integer j -&gt; to(wide) works
clear
input id year x
1 1 10
1 2 11
2 1 20
2 2 21
end
label define yl 1 &quot;wave one&quot; 2 &quot;wave two&quot;
label values year yl
reshapehelper, to(wide)
assert &quot;`r(status)'&quot; == &quot;ok&quot;
assert r(tested) == 1

* (k) REGRESSION (adversarial finding): a chained run followed by a
*     single-step run must CLEAR the stale second-step global
clear
input famid ht_k1_t1 ht_k1_t2 ht_k2_t1 ht_k2_t2
1 3.1 3.6 4.0 4.4
2 3.3 3.8 4.1 4.6
end
reshapehelper
assert `&quot;$reshapehelper_cmd2&quot;' != &quot;&quot;
clear
input id inc80 inc81
1 5000 5500
2 2000 2200
end
reshapehelper
assert `&quot;`r(cmd2)'&quot;' == &quot;&quot;
assert `&quot;$reshapehelper_cmd2&quot;' == &quot;&quot;
* ... and a checklist run clears the first global too
sysuse auto, clear
reshapehelper
assert &quot;`r(status)'&quot; == &quot;needinfo&quot;
assert `&quot;$reshapehelper_cmd&quot;' == &quot;&quot;

* (l) varlist restriction scopes the SCAN but not the id hunt
clear
input id inc80 inc81 ue80 ue81
1 5000 5500 0 1
2 2000 2200 1 0
end
reshapehelper inc80 inc81
assert &quot;`r(status)'&quot; == &quot;ok&quot;
assert strpos(`&quot;`r(cmd)'&quot;', &quot;reshape long inc, i(id)&quot;) &gt; 0
assert strpos(`&quot;`r(cmd)'&quot;', &quot;ue&quot;) == 0

* (m) user errors arrive as clean return codes
capture reshapehelper, i(no_such_var)
assert _rc == 111
capture reshapehelper, to(wide) j(no_such_var)
assert _rc == 111
clear
input id z1 z2
1 1 2
2 3 4
end
reshapehelper, to(long) stubs(qqq) i(id)
assert inlist(&quot;`r(status)'&quot;, &quot;blocked&quot;, &quot;needinfo&quot;)

* ---------------------------------------------------------------------------
* T22. REGRESSION (adversarial round 2): a double-quote inside a string j
*      VALUE must not crash the caller (it broke the 32-char length test)
* ---------------------------------------------------------------------------
clear
input id str8 size measure
1 &quot;5in&quot; 10
1 &quot;6in&quot; 20
2 &quot;5in&quot; 11
2 &quot;6in&quot; 21
end
replace size = subinstr(size, &quot;in&quot;, char(34), .)   // values become  5&quot;  6&quot;
capture reshapehelper, to(wide) j(size)
assert _rc == 0                                     // no escaped r(132)/r(198)
assert inlist(&quot;`r(status)'&quot;, &quot;ok&quot;, &quot;blocked&quot;, &quot;needinfo&quot;)
assert _N == 4 &amp; c(k) == 3                          // data untouched
* a backtick in a j value must also be safe
clear
input id str8 code measure
1 &quot;a&quot; 10
1 &quot;b&quot; 20
2 &quot;a&quot; 11
2 &quot;b&quot; 21
end
replace code = &quot;a&quot; + char(96) + &quot;b&quot; if code == &quot;a&quot;
capture reshapehelper, to(wide) j(code)
assert _rc == 0
assert inlist(&quot;`r(status)'&quot;, &quot;ok&quot;, &quot;blocked&quot;, &quot;needinfo&quot;)

* ---------------------------------------------------------------------------
* T23. REGRESSION: the &quot;i() still contains the factor&quot; note must NOT fire on a
*      terminal single-id panel (it was misreading the id as a leftover factor)
* ---------------------------------------------------------------------------
clear
input id year inc
1 80 5000
1 81 5500
2 80 2000
2 81 2200
3 80 3000
3 81 3300
end
reshapehelper, to(wide)
assert &quot;`r(status)'&quot; == &quot;ok&quot;
assert strpos(`&quot;`r(cmd)'&quot;', &quot;reshape wide inc, i(id) j(year)&quot;) &gt; 0
assert `&quot;`r(note)'&quot;' == &quot;&quot;                          // no spurious factor note
* but a genuine compound-i leftover factor STILL earns the note (T14 shape)
clear
input hid str1 sex year inc
1 &quot;f&quot; 90 3200
1 &quot;f&quot; 91 4700
1 &quot;m&quot; 90 4500
1 &quot;m&quot; 91 4600
2 &quot;f&quot; 90 3600
2 &quot;f&quot; 91 3800
2 &quot;m&quot; 90 5100
2 &quot;m&quot; 91 5300
end
reshapehelper, to(wide)
assert &quot;`r(status)'&quot; == &quot;ok&quot;
assert `&quot;`r(note)'&quot;' != &quot;&quot;

* ---------------------------------------------------------------------------
* T24. REGRESSION: r(direction) only ever returns a DOCUMENTED value
* ---------------------------------------------------------------------------
clear
input a b c
1 2 3
4 5 6
end
reshapehelper, to(long)
assert inlist(&quot;`r(direction)'&quot;, &quot;wide2long&quot;, &quot;long2wide&quot;, &quot;doubly&quot;, &quot;unknown&quot;)
clear
input id x y
1 1 2
2 3 4
end
reshapehelper, to(wide)
assert inlist(&quot;`r(direction)'&quot;, &quot;wide2long&quot;, &quot;long2wide&quot;, &quot;doubly&quot;, &quot;unknown&quot;)

* ---------------------------------------------------------------------------
* T25. Sparse panel: an id that DOES uniquely identify rows with year but
*      barely repeats is set aside by the plausibility bar; the checklist must
*      name it as a possible sparse-units cause and expose it in r(sparse)
* ---------------------------------------------------------------------------
clear
input id year x
1 2019 10
2 2019 20
3 2019 30
4 2019 40
5 2020 50
1 2020 11
end
reshapehelper, to(wide)
assert &quot;`r(status)'&quot; == &quot;needinfo&quot;
assert &quot;`r(sparse)'&quot; == &quot;id&quot;
assert `&quot;`r(cmd)'&quot;' == &quot;&quot;
* forcing the flagged id makes it resolve
reshapehelper, to(wide) i(id) j(year)
assert &quot;`r(status)'&quot; == &quot;ok&quot;
assert strpos(`&quot;`r(cmd)'&quot;', &quot;reshape wide x, i(id) j(year)&quot;) &gt; 0
* a normal (non-sparse) panel must NOT set r(sparse)
clear
input id year x
1 80 5
1 81 6
2 80 7
2 81 8
end
reshapehelper, to(wide)
assert &quot;`r(status)'&quot; == &quot;ok&quot;
assert &quot;`r(sparse)'&quot; == &quot;&quot;</pre>
</div>]]></content:encoded>
			<category domain="https://www.statalist.org/forums/forum/general-stata-discussion/general">General</category>
			<dc:creator>eric_a_booth</dc:creator>
			<guid isPermaLink="true">https://www.statalist.org/forums/forum/general-stata-discussion/general/1786886-reshapehelper-on-ssc</guid>
		</item>
		<item>
			<title>Data file not opening</title>
			<link>https://www.statalist.org/forums/forum/general-stata-discussion/general/1786883-data-file-not-opening</link>
			<pubDate>Fri, 31 Jul 2026 11:22:52 GMT</pubDate>
			<description>Hello! 
I am new to STATALIST. I have subscription of STATA 19 SE. When I am trying to open a STATA file from another source, it is not opening and...</description>
			<content:encoded><![CDATA[Hello!<br />
I am new to STATALIST. I have subscription of STATA 19 SE. When I am trying to open a STATA file from another source, it is not opening and giving this error message &quot;dataset too large<br />
    This dataset was created by Stata/MP and has more variables than your Stata can handle.&quot;<br />
How can I overcome this problem with the current STATA subscription?]]></content:encoded>
			<category domain="https://www.statalist.org/forums/forum/general-stata-discussion/general">General</category>
			<dc:creator>Sumit Mahajan</dc:creator>
			<guid isPermaLink="true">https://www.statalist.org/forums/forum/general-stata-discussion/general/1786883-data-file-not-opening</guid>
		</item>
		<item>
			<title>logistic_scores is now available on SSC</title>
			<link>https://www.statalist.org/forums/forum/general-stata-discussion/general/1786878-logistic_scores-is-now-available-on-ssc</link>
			<pubDate>Fri, 31 Jul 2026 09:32:22 GMT</pubDate>
			<description><![CDATA[Thanks as always to Kit Baum, a new command logistic_scores is now available from SSC. Stata 9 is required. 
 
It's all about generating logistic...]]></description>
			<content:encoded><![CDATA[Thanks as always to Kit Baum, a new command <span style="font-family:courier new">logistic_scores </span><span style="font-family:arial">is now available from SSC. Stata 9 is required.<br />
<br />
It's all about generating logistic scores, a transformation of graded ordinal variables best publicised in Frederick Mosteller and John W. Tukey's book <i>Data Analysis and Regression </i>(1977). The idea can also be seen in a long paper by Tukey written in 1961 but not published until 1986.<br />
<br />
This is a slow-running project, I posted some Mata code on Statalist in 2007, got around to writing a command in 2015, and tweaked it in 2022, and finally wrote up a help file this month.<br />
<br />
The definitions and even the derivation of the recipe are all in the help file and an ancillary document and its references.<br />
<br />
Take any example of such a variable. Many Stata users will know that the </span><span style="font-family:courier new">auto </span><span style="font-family:arial">dataset includes </span><span style="font-family:courier new">rep78 <span style="font-family:arial">--</span> </span><span style="font-family:arial">which is repair record 1978 on a five-point scale with numeric values 1 to 5.<br />
<br />
Here is a graph to show what this command produces for that variable. </span><br />
  <a href="filedata/fetch?filedataid=1786879">Array </a><br />
 <br />
<span style="font-family:arial">And here as a second example are some anonymous or at least unexplained data from Mosteller and Tukey, included so that I could check that the command produced the same results. </span><br />
  <a href="filedata/fetch?filedataid=1786880">Array </a><br />
 People not interested in this command might nevertheless be interested in the small graphical tricks for producing such displays. Complete code is included in the help file.<br />
<br />
<span style="font-family:arial">In two sentences, perhaps not intelligible until you've read the longer accounts: Cumulative probabilities define breakpoints between slices of an underlying distribution taken be standard logistic. Scores are then returned as the centres of gravity of those slices.<br />
<br />
How far the original variables say something about whatever is being graded, or something about the people doing the grading, is a topic for discussion. Either way or both ways, they are the data we have.<br />
<br />
Many people reading this will have been exposed to a classification of measurement scales or levels into nominal, ordinal, interval, and ratio, That classification was revisited repeatedly in articles (and a book) by the psychologist Stanley Smith Stevens from 1946 to 1975 (the last publication was posthumous). The way it is cited varies across the entire range from purely descriptive to strongly prescriptive -- or even strongly proscriptive. </span><br />
<br />
One common argument runs that for variables like this with values 1 2 3 4 5 are, as said, just ordinal grades conventionally reported as successive integers, but not otherwise to be taken literally, which means numerically. We don't have licence, the argument runs, to treat intervals such as 2 minus 1 or 3 minus 2 as equal or even as meaning anything in particular. So the scale lacks the property that intervals can be taken literally. Still less can we take it that 2 is twice 1, 4 is twice 2, and so on. Ratios can be formed, but not legitimately. So far, so correct, but does that affect what we can do (should do) statistically? Have you heard the line that only medians make sense for such variables, and that means can't be used validly? Do you agree in principle? In your statistical practice?<br />
<br />
Despite this caution much of the practice of data analysis ignores or even defies any purism about measurement scales. <span style="font-family:courier new">summarize</span> (for example) will without a murmur of discontent take such a variable and calculate not just means, but also SD, skewness and kurtosis, and so forth. Is that valid or useful? Stata's attitude, as with most comparable software, is that yours is the choice to make, and yours is the responsibility. More broadly, any number of websites post average review scores, not to mention what many universities do with student grades or marks.<br />
<br />
On a less abstract level: How do people use such variables? Perhaps the easiest decision to make is to treat a variable like <span style="font-family:courier new">rep78 </span>through a set of indicator variables when it is regarded as a predictor or covariate. That answers, or avoids, qualms about measurement scale. It is letting the data show how the variable works in practice. Depending on results, researchers might leave the variable as indicators, to be emboldened to replace it with the data as it came, to use a quadratic instead, and so on.<br />
<br />
Logistic scores are also a variant on the letting the data show how the variable works in practice. The easy part to buy is that cumulative probabilities are well defined if anything is with such a variable. The last cumulative probability is identically 1. Otherwise we have (usually) one fewer cumulative probability than categories acting as breakpoints between slices of a distribution.<br />
<br />
More arbitrary is positing an underlying logistic distribution. The argument for that pivots on simplicity and tractability: the scores for each slice fall out as a result of a moderately simple calculation, as now done for you by this command.<br />
<br />
I wouldn't usually use logistic scores as a predictor without checking whether alternatives, notably indicator variables, give broadly similar results.<br />
<br />
What about logistic scores as an outcome? Recently I heard of a variable like <span style="font-family:courier new">rep78</span> being used as an outcome in multiple regression as it came. I had to suppress as commentary what I suppose is a fairly standard line that you should be trying something quite different instead, say ordinal logit -- or ordinal probit, or any number of alternative ordinal models from categorical data analysis. I readily confess to a chicken and egg reluctance to get involved with these models. That is, you need to use them routinely before you can wrap your head around which one to use, what to look for, and how to explain them. So, although there is always a need to check whether linearity works well enough I don't want to write off that kind of application, and now have an alternative to suggest.]]></content:encoded>
			<category domain="https://www.statalist.org/forums/forum/general-stata-discussion/general">General</category>
			<dc:creator>Nick Cox</dc:creator>
			<guid isPermaLink="true">https://www.statalist.org/forums/forum/general-stata-discussion/general/1786878-logistic_scores-is-now-available-on-ssc</guid>
		</item>
		<item>
			<title>New version of kmest on SSC</title>
			<link>https://www.statalist.org/forums/forum/general-stata-discussion/general/1786874-new-version-of-kmest-on-ssc</link>
			<pubDate>Fri, 31 Jul 2026 00:39:53 GMT</pubDate>
			<description>Thanks as always to Kit Baum, a new version of the kmest package is now available for download from SSC. In Stata, use the ssc command to do this, or...</description>
			<content:encoded><![CDATA[Thanks as always to Kit Baum, a new version of the <span style="font-family:courier new">kmest </span>package is now available for download from SSC. In Stata, use the <span style="font-family:courier new">ssc</span> command to do this, or <span style="font-family:courier new">adoupdate</span> if you already have an old version of <span style="font-family:courier new">kmest</span>.<br />
<br />
The <span style="font-family:courier new">kmest</span> package is described as below on my website. The new version returns the results <span style="font-family:courier new">e(wtype)</span> and<span style="font-family:courier new"> e(wexp)</span>, containing the type and expression of the weights used (if any). It has also been given additional test sequences in its certification script.<br />
<br />
Best wishes<br />
<br />
Roger<br />
<br />
<span style="font-family:courier new">-----------------------------------------------------------------------------------------------------------------------------------------------------------<br />
package kmest from <a href="https://www.rogernewsonresources.org.uk/stata16" target="_blank">https://www.rogernewsonresources.org.uk/stata16</a><br />
-----------------------------------------------------------------------------------------------------------------------------------------------------------<br />
<br />
TITLE<br />
      kmest: Compute Kaplan-Meier survival probabilities and/or percentiles as estimation results<br />
<br />
DESCRIPTION/AUTHOR(S)<br />
      kmest is intended for use in a survival time dataset set up by stset.<br />
      It computes Kaplan-Meier survival probabilities (as computed by sts<br />
      generate) for a list of times (sorted in ascending order), and/or<br />
      Kaplan-meier percentiles for a list of percents (srted in ascending<br />
      order), and saves them as estimation results, without a variance<br />
      matrix.  kmest is intended for use with the bootstrap prefix, or<br />
      possibly with the jackknife prefix, to create confidence intervals for<br />
      the Kaplan-Meier survival probabilities and/or percentiles, possibly<br />
      allowing for clustering and/or sampling-probability weighting.<br />
      Alternatively, kmest can be used with the SSC packages parmest and<br />
      esetran to compute Greenwood confidence intervals, or delta-Greenwood<br />
      confidence intervals using a variety of Normalizing transforms.<br />
      <br />
      Author: Roger Newson<br />
      Distribution-Date: 30 July 2026<br />
      Stata-Version: 16<br />
<br />
INSTALLATION FILES                                  (click here to install)<br />
      kmest.ado<br />
      kmest_p.ado<br />
      kmest.sthlp<br />
-----------------------------------------------------------------------------------------------------------------------------------------------------------<br />
(click here to return to the previous screen)</span><br />
<br />
 ]]></content:encoded>
			<category domain="https://www.statalist.org/forums/forum/general-stata-discussion/general">General</category>
			<dc:creator>Roger Newson</dc:creator>
			<guid isPermaLink="true">https://www.statalist.org/forums/forum/general-stata-discussion/general/1786874-new-version-of-kmest-on-ssc</guid>
		</item>
	</channel>
</rss>
