Dear Prof. Lucchetti, Thank you very much for your excellent solution. I used your code and joined the two sets very well. With best regards Dhanasekaran K
On Wed, Jan 17, 2024 at 5:03 PM Dhanasekaran Kuppusamy <drgkd...@gmail.com> wrote: > Thank you very much for your solution,Prof. Lucchetti. I will try to join > the data sets with your code. > With best regards > Dhanasekaran K > > On Wed, 17 Jan 2024 at 3:13 PM, Riccardo (Jack) Lucchetti < > p002...@staff.univpm.it> wrote: > >> On 17/01/2024 12:34, Dhanasekaran Kuppusamy wrote: >> > Dear Gretl community*, >> > * I have two datasets A and B. >> > Both A and B have different variables but with common variable i.e. ID. >> > I want to merge these two data sets using ID as the common variable as >> > given below : data set C. Thanking you in advanceI would be thankful >> for >> > providing the solution. Note: A : Household data and B members data. >> > >> > Dhanasekaran K >> >> Generally speaking, what you need is the "join" command.: assuming your >> two example dataset are in gdt format (but csv would work just as well), >> you can add the data from A to B via >> >> <hansl> >> open dataset_b.gdt >> join dataset_a.gdt x1 x2 x3 --ikey=ID >> </hansl> >> >> Reformatting the data as you dataset C is less easy, since you can't >> assume that each household has the same number of members. The following >> example shows what happens if you set the maximum number of family >> members to 3: >> >> <hansl> >> open dataset_a.gdt >> >> maxn = 3 >> >> loop i = 1 .. maxn >> loop foreach j x4 x5 >> sname = sprintf("$j_%d", i) >> join dataset_b.gdt @sname --data=$j --ikey=ID --aggr="seq:$i" >> endloop >> endloop >> </hansl> >> >> Having said all this, I'd recommend reading the Guide chapter titled >> "Joining data sources". >> >> ------------------------------------------------------- >> Riccardo (Jack) Lucchetti >> Dipartimento di Scienze Economiche e Sociali (DiSES) >> >> Università Politecnica delle Marche >> (formerly known as Università di Ancona) >> >> r.lucche...@univpm.it >> http://www2.econ.univpm.it/servizi/hpp/lucchetti >> ------------------------------------------------------- >> _______________________________________________ >> Gretl-users mailing list -- gretl-users@gretlml.univpm.it >> To unsubscribe send an email to gretl-users-le...@gretlml.univpm.it >> Website: >> https://gretlml.univpm.it/postorius/lists/gretl-users.gretlml.univpm.it/ >> >
_______________________________________________ Gretl-users mailing list -- gretl-users@gretlml.univpm.it To unsubscribe send an email to gretl-users-le...@gretlml.univpm.it Website: https://gretlml.univpm.it/postorius/lists/gretl-users.gretlml.univpm.it/