Solved
New Contributor
Posts: 4

# How to Insert 31 rows between any two rows

Hi there,

I have a very large data sets of daily perspiration like this:

ID YEAR MONTH DAY1 DAY2 DAY3 .... DAY31

A1    1911   1            12     23      1      ...      34

A1    1911    2           23   34       45     ...       .

....

For each year, I have 12 months, and day1 to day31 lists the values for each day.

I want to list each day as a row:

ID YEAR MONYH DAY VALUE

A1  1911   1          1        12

A1   1911  1         2          23

...

A1   1911  1        31         34

....

A1    1911  2       1          23

A1    1911  2       2          34

...

I'm thinking to insert 31 rows  between every two rows and read the value from corresponding day. I have no clue whether this makes sense. Your help is very much appreciated!

Stella

Accepted Solutions
Solution
‎05-02-2012 10:26 PM
Posts: 3,167

## Re: How to Insert 31 rows between any two rows

It seems to me that proc transpose will get what you want; please check out the following 4-day examples:

data have;

input (ID YEAR MONTH DAY1-DAY4) (:\$);

cards;

A1    1911   1            12     23      1    34

A1    1911    2           23   34       45    52

;

proc transpose data=have out=want (rename=(_name_=day col1=value));

by id year month;

var day1-day4;

run;

proc print;run;

Regards,

Haikuo

All Replies
Solution
‎05-02-2012 10:26 PM
Posts: 3,167

## Re: How to Insert 31 rows between any two rows

It seems to me that proc transpose will get what you want; please check out the following 4-day examples:

data have;

input (ID YEAR MONTH DAY1-DAY4) (:\$);

cards;

A1    1911   1            12     23      1    34

A1    1911    2           23   34       45    52

;

proc transpose data=have out=want (rename=(_name_=day col1=value));

by id year month;

var day1-day4;

run;

proc print;run;

Regards,

Haikuo

New Contributor
Posts: 4

## Re: How to Insert 31 rows between any two rows

It works perfectly, thank you very much, Haikuo!

🔒 This topic is solved and locked.