Questions tagged [readstata13]

12 questions
2
votes
0 answers

pandas.read_stata() error:unpack requires a buffer of 4 bytes

I want to read a .dta dataset using pandas read_stata(): import pandas as pd df=pd.read_stata('data_chunk1.dta') But I get an error about unpack buffer: --------------------------------------------------------------------------- error …
1
vote
0 answers

a binary read error occurred when using read.dta13 on a .dta file

I am trying to load in a STATA data file using read.dta13 from the readstata13 library. When I use the function read.dta13 on this .dta file I get the following error over and over: char: a binary read error occurred. What does this mean? Here is…
0
votes
1 answer

How to recode separate variables from a multiple response survey question into one variable

I am trying to recode a variable that indicates total number of responses to a multiple response survey question. Question 4 has options 1, 2, 3, 4, 5, 6, and participants may choose one or more options when submitting a response. The data is…
devlex
  • 1
  • 1
0
votes
1 answer

repeated time values within panel (r451)

I'm really new on Stata and I'm trying to work with a panel data. I know that, to set a panel data, one uses xtset id year, but when I try to use this command Stata returns the error "repeated time values within panel (r451)". I know that this…
0
votes
1 answer

Shorter way to reference every previous time-series year of a variable using tsset?

So say I have a dataset like this: Country year poverty rate sales Austria 1950 0.54 142 Austria 1951 0.32 12441 Austria 1952 0.32 12441 Bangladesh 1950 0.11 142123123 Bangladesh 1951 0.52 1234 Bangladesh 1952 0.32 12441 Sri…
0
votes
1 answer

How do I do tsset with this specific dataset?

My dataset looks like this: Country year poverty rate sales Austria 1950 0.54 142 Austria 1951 0.32 12441 Austria 1952 0.32 12441 Bangladesh 1950 0.11 142123123 Bangladesh 1951 0.52 1234 Bangladesh 1952 0.32 12441 Sri…
0
votes
1 answer

Problems when importing factor variables from Stata using readstata13 package

I have a very odd problem. I'm importing some factor variables from Stata into R using readstata13 package. The imported labels/levels look ok, but they change when removing factor class. Here is the Stata description of the variable (here is the…
luchonacho
  • 6,759
  • 4
  • 35
  • 52
0
votes
1 answer

How to reshape a specific dataset from long to wide without a J variable in Stata?

My dataset looks like the following: identification…
0
votes
1 answer

Stata loop to retrieve data from Excel file

My Excel file has many sheets. I am trying to create a loop to retrieve every sheet of data to be able to save it as .dta. This is my code: local sheet = `" "Data dictionary" "Wave 1" "Wave 2" "Wave 3" "Wave 4" "' foreach x of local sheets{ …
A01066656
  • 25
  • 4
-1
votes
1 answer

Error merging files: . Error says that variable CLAIM_NUMBER does not uniquely identify observations in the using data. How do I fix that?

In Stata, the error says that variable CLAIM_NUMBER does not uniquely identify observations in the using data. How do I fix that? My code: cd"abcd" use NY2019_2021 merge m:1 CLAIM_NUMBER using FULLNY keep if _merge==3 drop _merge```
san
  • 1
  • 2
-1
votes
1 answer

How can I generate AGE categorical/binary variable?

I tried using the below code but it throws an error in Stata. gen agecat=. replace agecat=1 if age<=20 replace agecat=2 if age==21-30 replace agecat=2 if age==31-40 replace agecat=2 if age>=64
san
  • 1
  • 2
-2
votes
3 answers

How do I generate age category? My PATIENT_YOB is given as 01jan1956 and I want to get exact age

I'm trying to use the following code but it gives error 01jan1986 05jan2001 07mar1983 and so on I need to get the exact age of them gen agecat=1 if age 0-20==1 if age 21-40==2 if age 41-60==3 if age 61-64==4```
san
  • 1
  • 2