reshape wide to long dataset

31 views
Skip to first unread message

vuth...@hmu.edu.vn

unread,
Feb 23, 2016, 12:07:38 PM2/23/16
to Stata Users Forum
Hi there,

I want to convert my wide dataset to long dataset, using the command reshape long a, i(ID) j(b). The odd thing happend is that stata cannot recognize the ID variable. It said " variable ID should uniquely identify the observations". 

Do anyone know what the problem is? Please help.


Best,


Lina

Eric A. Booth

unread,
Feb 23, 2016, 12:30:43 PM2/23/16
to vuth...@hmu.edu.vn, Stata Users Forum
It recognizes the id variable, that is not the problem.  You'll need to remove the duplicates in the ID variable.  I suspect you have some sort of panel data where the ID var is repeated and so you'd need to specify multiple variables to identify the panel.  Something like ID & year or ID and company.  To inspect whether your ID variable uniquely identifies the observations (as reshape requires), use the following commands:

isid ID
duplicates report ID
isid ID year
duplicates report ID year


If this is not the source of the problem, you'd need to show a minimum working example of your data structure and the -reshape- code you ran in order for someone to be able to diagnose your issue.


--
You received this message because you are subscribed to the Google Groups "Stata Users Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stata-users-fo...@googlegroups.com.
To post to this group, send email to stata-us...@googlegroups.com.
Visit this group at https://groups.google.com/group/stata-users-forum.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages