user6241156
user6241156

Reputation: 1

SAS summary data transposed to line list?

I have a data set like this

YEAR GENDER RACE AGE COUNT
2015  Female W   30    3

So in 2015, there were 3 White 30 year females. I'd like to transpose this into line list data, like this:

YEAR GENDER RACE AGE 
2015 Female W    30
2015 Female W    30
2015 Female W    30 

Any help would be greatly appreciated! Thank you!

Upvotes: 0

Views: 35

Answers (1)

udden2903
udden2903

Reputation: 783

I added a row for purpose of illustration:

data have;
    input YEAR GENDER $ RACE $ AGE COUNT;
    datalines;
    2015 Female W 30 3
    2014 Male B 45 4
;

The following code will hopefully accomplish what you are asking for:

data want (drop=i count);
    set have;

    do i = 1 to count;
        output;
    end;
run;

Upvotes: 1

Related Questions