

This is similar to executing a series of. When the cell magic command stata is used, a block of Stata commands can be specified and executed all at once. When the line magic command stata is used, a one-line Stata command can be specified and executed, as it would be in Stata’s Command window. I would appreciate any insight into the differences in how the codebook displays %tc vs. Execute one line or a block of Stata commands. list date1 // However this output IS as I expect! Yay! (But why doesn't the codebook reflect the %tc formatting?) codebook date1 // Output is not as I expect, there is no indication that date1 is formatted as a date-time variable. format date1 %tc // Applying date-time formatting so the variable is human-readable. codebook date1 // Starting with a numeric variable.

Then save the auto dataset as a CSV file.

(To access this in Stata, simply type ' sysuse auto.dta' ) Method 1: Open up Stata and load the auto dataset. Why doesn't the -codebook- command produce output with a human-readable date1? Task 1: Import and open a Stata dataset Lets take Statas famous auto dataset, which you may have heard of. In contrast, when I apply %tc formatting to a numeric variable, the codebook does NOT indicate it is a date-time variable, even though the variable displays as a date-time the way I want it to when using the -browse- or -list- commands, as shown with date1 below. With no description of what your purpose is, that summarize will not fulfill, any attempt to make a recommendation would be guesswork. Or equivalently: Units: daysĢ6aug2022 06sep2022 04oct2022 04nov2022 29nov2022 There is a max() function, and the egen command includes a max() function. codebook date2 // Output is as I expect-Yay! The table below shows you five columns of information. format date2 %td // Applying daily date formatting so the variable is human-readable. For example, you want to make a new variable and know you can use the compute command to create a new variable in SPSS, but what is the equivalent (or similar) command in Stata (By the way, there are actually three similar Stata commands, generate, replace and egen ). codebook date2 // Starting with a numeric variable. This makes sense to me-I have a numeric variable, and because I applied the %td format, Stata knows it is a daily date, and the codebook tells me so. I am wondering whether there is a bug in the Stata 17 codebook command affecting what it indicates about the %tc date-time format, or whether I am misunderstanding date-time formats?īackground: When I have applied the %td format to a numeric variable, the codebook tells me that the variable is a daily date, as shown with date2 in the example below.
