stata

Destring a time variable using Stata

浪子不回头ぞ 提交于 2020-01-07 11:29:30
问题 How to destring a time variable (7:00) using Stata? I have tried destring : however, the : prevents the destring . I then tried destring, ignore(:) but was unable to then make a double and/or format %tc . encode does not work; recast does not do the job. I also have a separate string date that I was able to destring and convert to a double . Am I missing that I could be combining these two string variables (one date, one time) into a date/time variable or is it correct to destring them

Destring a time variable using Stata

ぐ巨炮叔叔 提交于 2020-01-07 11:29:14
问题 How to destring a time variable (7:00) using Stata? I have tried destring : however, the : prevents the destring . I then tried destring, ignore(:) but was unable to then make a double and/or format %tc . encode does not work; recast does not do the job. I also have a separate string date that I was able to destring and convert to a double . Am I missing that I could be combining these two string variables (one date, one time) into a date/time variable or is it correct to destring them

How to run a regression which report all factor variables?

寵の児 提交于 2020-01-06 06:55:53
问题 I want to run a regression that calculates the estimated values for all levels of a factor variable. By default, Stata omits one dummy as a base level. When I use the allbaselevels option, it just shows a zero value for a base level: regress adjusted_volume i.rounded_time, allbaselevels SAS shows all the estimated values of categorical variables when the constant has been removed. How can i do the same thing in Stata? 回答1: The option allbaselevels is one of several display options , which can

How to delete obs for a month

狂风中的少年 提交于 2020-01-06 06:16:10
问题 Here is an example of my data: * Example generated by -dataex-. To install: ssc install dataex clear input str6 Name double Value long Date "ABAD1" 1019 18856 "ABAD1" 1149 19430 "ABAD1" 1160 19423 "ABAD1" 1160 19388 "ABAD1" 1220 19380 "ABAD1" 1220 19380 "ABAD1" 1228 19377 "ABAD1" 1228 19377 "ABAD1" 1300 19373 "ABAD1" 1311 19294 "ABAD1" 1311 19252 "ABAD1" 1315 19212 "ABAD1" 1354 19359 "ABAD1" 1360 19357 "ABAD1" 1381 19351 "ABAD1" 1408 19352 "ABAD1" 1394 19191 "ABAD1" 1415 18986 "ABAD1" 1475

Stata to Pandas: even if there are repeated Value Labels?

狂风中的少年 提交于 2020-01-06 05:52:35
问题 i try to open a .dta as DataFrame. But an Error appears: "ValueError: Value labels for column ... are not unique. The repeated labels are:" followed by labels wich apper twice in a column. I know labeling multiplie codes with the exact same value label in stata is not clever (not my fault :)) After some research i know, pandas will not accept repeated value labels (this IS clever). But i can't figure out a (good) solution: Is there: a. a smooth way to open the data with pandas and just rename

Stata to Pandas: even if there are repeated Value Labels?

為{幸葍}努か 提交于 2020-01-06 05:52:26
问题 i try to open a .dta as DataFrame. But an Error appears: "ValueError: Value labels for column ... are not unique. The repeated labels are:" followed by labels wich apper twice in a column. I know labeling multiplie codes with the exact same value label in stata is not clever (not my fault :)) After some research i know, pandas will not accept repeated value labels (this IS clever). But i can't figure out a (good) solution: Is there: a. a smooth way to open the data with pandas and just rename

Get the number of tokens using a specific parsing character

北慕城南 提交于 2020-01-06 04:55:14
问题 Consider the following toy string: my first name is Pearly, and my surname is Spencer Is there an out-of-the-box way in Stata (mata included) to get the number of tokens based on a user-specified parsing character? In this particular example, two tokens separated by a comma. Solutions like the macro extended function for parsing word count use a space and I would like to avoid writing a program for this. 回答1: The number of tokens is the number of parsing characters PLUS 1. That being so,

How to load subset of dta/Stata file with R

拟墨画扇 提交于 2020-01-06 03:17:04
问题 Coming from Stata this seems to be an easy thing, though I cannot find a solution with R, though I read How to read a subset of large dataset in R? Is it possible as it is in Stata to name the variables from a dataset I need and load just them? Is it then possible to name again specific variables from another data set and merge them? 回答1: I haven't tested it myself, but the latest version of the readstata13 package seems to allow for subsetting on both columns and rows: read.dta13(file,

Stata: foreach creates too many variables -

时光总嘲笑我的痴心妄想 提交于 2020-01-05 08:14:13
问题 I created a toy example of my code below. In this toy example I would like to create a measure of all higher prices minus lower prices within a self-created reference group. So within each reference group, I would like to take each individual and subtract its price value from all higher price values from other individuals in the same group. I do not want to have negative differences. Then I would like to sum all these differences. In creating this code I found some help here: http://www.stata

Simple way to do a weighted hot deck imputation in Stata?

浪尽此生 提交于 2020-01-05 06:21:08
问题 I'd like to do a simple weighted hot deck imputation in Stata. In SAS the equivalent command would be the following (and note that this is a newer SAS feature, beginning with SAS/STAT 14.1 in 2015 or so): proc surveyimpute method=hotdeck(selection=weighted); For clarity then, the basic requirements are: Imputations most be row-based or simultaneous. If row 1 donates x to row 3, then it must also donate y . Must account for weights. A donor with weight=2 should be twice as likely to be