0% found this document useful (0 votes)
24 views2 pages

I Need A Dataset To Be Transposed Like

The document contains two data queries. The first query asks how to transpose a dataset to rearrange the columns and rows. The dataset contains growth measurements for different IDs across multiple years. The second query asks to reshape another dataset containing growth measurements for individuals across different ages into a longitudinal format with one row per individual-age combination.

Uploaded by

lanka.cnu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

I Need A Dataset To Be Transposed Like

The document contains two data queries. The first query asks how to transpose a dataset to rearrange the columns and rows. The dataset contains growth measurements for different IDs across multiple years. The second query asks to reshape another dataset containing growth measurements for individuals across different ages into a longitudinal format with one row per individual-age combination.

Uploaded by

lanka.cnu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Query # 1:

I have a dataset which looks like:


ID STAT YEAR1999 YEAR2000 YEAR2001 YEAR2002 YEAR2003;
a mean 19 20 21 22 23
a sd 119 120 121 122 123
a median 219 220 221 222 223
a iqr 319 320 321 322 323
b mean 419 420 421 422 423
b sd 519 520 521 522 523
b median 619 620 621 622 623
b iqr 719 720 721 722 723

I need a dataset to be transposed like:


Obs ID year mean sd median iqr
1 a YEAR1999 19 119 219 319
2 a YEAR2000 20 120 220 320
3 a YEAR2001 21 121 221 321
4 a YEAR2002 22 122 222 322
5 a YEAR2003 23 123 223 323
6 b YEAR1999 419 519 619 719
7 b YEAR2000 420 520 620 720
8 b YEAR2001 421 521 621 721
9 b YEAR2002 422 522 622 722
10 b YEAR2003 423 523 623 723
How can we transpose??????

Query # 2:
The data consist of growth measurements for 3 girls and 2 boys at ages 8, 10, 12 and 14,where y1 is the
measurement at age 8, y2 at age 10 and so forth. The data also has the age variable.

id

sex

21

20

22

23

10

12

14

20

24

26

27

10

12

14

19

20

22

25

10

12

14

24

27

28

29

10

12

14

12

y1

22

I need an output like:

01 F 21 8
01 F 20 10
01 F 22 12
01 F 23 14
04 F 20 8
.................
.................
12 M 25 14

y2

21

y3

23

y4

25

a1

a2

10

a3

12

a4

14

You might also like