Hello! I am somewhat new to Stata and have tried to find an answer to this on other threads but have been unable to find something that works with my dataset. I have attached a snippet from my dataset. I have upwards to 6,000 observations, so you could see why I am trying to find a way to code for this issue.
This is a dietary recall dataset. I am trying to begin data cleaning, and one of my parameters is that I only want to include subjects that have recalls from two days (as opposed to only one). I am having trouble coming up with a way where I can ultimately create a variable and code it 0/1 for if they have recalls for two days or not. As you can see, the number of entries for each ID can vary greatly. Some have 6 while others have up to 14. This obviously doesn't matter when I just need to verify that I have recalls for two days, but it does make it a little tricky to handle since I can't reshape the data. Can someone lend some insight on how to handle this? I am open to hearing other suggestions that may be better than what I'm trying to do as well.
I appreciate any and all help I can get with this.
Related Posts with How to identify if each ID has two unique values for a variable
using * in a for-loopHello, I can't figure out what does * mean in front of a for-loop. Here you can see an example: fo…
Identifying peaks and throughsDear all, By following the method of Bry and Boschan (1971), full reference placed below, I want to…
tabulate two variables to show the value of a third variable; save dataset as matrix; multiple plots using plotmatrixHi all, I have data: Code: * Example generated by -dataex-. To install: ssc install dataex clear…
Calculate pairwise differencesHi friends, I have data: Code: * Example generated by -dataex-. To install: ssc install dataex cl…
Out-of-sample logit: applying estimated coefficients on a new series (w/o observing 0s/1s)Hello STATA community, This is both a methodological question and a programming question, for which…
Subscribe to:
Post Comments (Atom)
0 Response to How to identify if each ID has two unique values for a variable
Post a Comment