## PROC TRANSPOSE Doubts and needing some clues

Frequent Contributor
Posts: 115

# PROC TRANSPOSE Doubts and needing some clues

Hi there my SAS friends:

One more time here, it's me (LOL). Needing some important help.

Let me show you what exactly i am looking for many years ago, really, YEARS, but, here i go!

ill show you the examplethat i1m trying to solve:

data Transpose1;

input Tratamento\$ repet Field_1 Field_2 Field_3 Field_4 Field_5;

cards;

A_ai 1 4 2 2 3 3

A_ai 2 3 2 2 4 2

A_ai 3 1 1 1 1 1

A_ai 4 1 2 1 1 2

A_ai 5 2 5 4 2 6

A_ai 6 1 1 1 1 1

A_ai 7 3 2 2 3 1

A_ai 8 2 2 3 4 3

A_ai 9 2 1 1 1 2

A_ai 10 1 2 1 1 1

;

PROC TRANSPOSE data=Transpose1 out=Transpose2 (drop=_;

by Tratamento;

var Field_1 Field_2 Field_3 Field_4 Field_5;

run;

proc print data=Transpose1;

run;

proc print data=Transpose2;

run;

so, there is all good, here is the problem, work with 10 lines of data is simple, cause in MS EXCEL, i can manage manually these 60 data, (it takes time for real), so i was wondering if you could help me to get this answer without tabulate manually in MS excel or some similar software:

data Example;

input Tratamento\$ repet Field Result;

cards;

A_ai 1 1 4

A_ai 1 2 2

A_ai 1 3 2

A_ai 1 4 3

A_ai 1 5 3

A_ai 2 1 3

A_ai 2 2 2

A_ai 2 3 2

A_ai 2 4 4

A_ai 2 5 2

A_ai 3 1 1

A_ai 3 2 1

A_ai 3 3 1

A_ai 3 4 1

A_ai 3 5 1

A_ai 4 1 1

A_ai 4 2 2

A_ai 4 3 1

A_ai 4 4 1

A_ai 4 5 2

A_ai 5 1 2

A_ai 5 2 5

A_ai 5 3 4

A_ai 5 4 2

A_ai 5 5 6

A_ai 6 1 1

A_ai 6 2 1

A_ai 6 3 1

A_ai 6 4 1

A_ai 6 5 1

A_ai 7 1 3

A_ai 7 2 2

A_ai 7 3 2

A_ai 7 4 3

A_ai 7 5 1

A_ai 8 1 2

A_ai 8 2 2

A_ai 8 3 3

A_ai 8 4 4

A_ai 8 5 3

A_ai 9 1 2

A_ai 9 2 1

A_ai 9 3 1

A_ai 9 4 1

A_ai 9 5 2

A_ai 10 1 1

A_ai 10 2 2

A_ai 10 3 1

A_ai 10 4 1

A_ai 10 5 1

;

proc print data=Example;

run;

So, the examples can be made by hand into excel or similar softwares, but it takes a lot of time.

Appreciate from the bottom of my heart your help.

Jonatan

Super User
Posts: 13,583

## Re: PROC TRANSPOSE Doubts and needing some clues

Posted in reply to jonatan_velarde

If I understand correctly you may be looking for something like:

data want (keep = Tratamento\$ repet Field Result );

set transpose1;

array f field1-field5;

do field = 1 to dim(f);

result = f[field];

output;

end;

run;

Frequent Contributor
Posts: 115

## Re: PROC TRANSPOSE Doubts and needing some clues

Thanks you very much and Excelent:

im obtaining this:

1 2 3 4 A_ai 1 1 . A_ai 1 2 . A_ai 1 3 . A_ai 1 4 . A_ai 1 5 . A_ai 2 1 . A_ai 2 2 . A_ai 2 3 . A_ai 2 4 . A_ai 2 5 . A_ai 3 1 . A_ai 3 2 . A_ai 3 3 . A_ai 3 4 . A_ai 3 5 . A_ai 4 1 . A_ai 4 2 . A_ai 4 3 . A_ai 4 4 . A_ai 4 5 . A_ai 5 1 . A_ai 5 2 . A_ai 5 3 . A_ai 5 4 . A_ai 5 5 . A_ai 6 1 . A_ai 6 2 . A_ai 6 3 . A_ai 6 4 . A_ai 6 5 . A_ai 7 1 . A_ai 7 2 . A_ai 7 3 . A_ai 7 4 . A_ai 7 5 . A_ai 8 1 . A_ai 8 2 . A_ai 8 3 . A_ai 8 4 . A_ai 8 5 . A_ai 9 1 . A_ai 9 2 . A_ai 9 3 . A_ai 9 4 . A_ai 9 5 . A_ai 10 1 . A_ai 10 2 . A_ai 10 3 . A_ai 10 4 . A_ai 10 5 .

just points

Thanks one more time

Frequent Contributor
Posts: 115

## Re: PROC TRANSPOSE Doubts and needing some clues

I found the erro:

Here

array f field1-field5;

and would be

array f field_1-field_5;

Thanks man, you saved my time

May the force be with you!!

Super User
Posts: 13,583

## Re: PROC TRANSPOSE Doubts and needing some clues

Posted in reply to jonatan_velarde

If you would mark the question as answered that will help the whole community.

Valued Guide
Posts: 864

## Re: PROC TRANSPOSE Doubts and needing some clues

Posted in reply to jonatan_velarde

I think this is what you are looking for:

data have;

input Tratamento\$ repet Field Result;

cards;

A_ai 1 1 4

A_ai 1 2 2

A_ai 1 3 2

A_ai 1 4 3

A_ai 1 5 3

A_ai 2 1 3

A_ai 2 2 2

A_ai 2 3 2

A_ai 2 4 4

A_ai 2 5 2

A_ai 3 1 1

A_ai 3 2 1

A_ai 3 3 1

A_ai 3 4 1

A_ai 3 5 1

A_ai 4 1 1

A_ai 4 2 2

A_ai 4 3 1

A_ai 4 4 1

A_ai 4 5 2

A_ai 5 1 2

A_ai 5 2 5

A_ai 5 3 4

A_ai 5 4 2

A_ai 5 5 6

A_ai 6 1 1

A_ai 6 2 1

A_ai 6 3 1

A_ai 6 4 1

A_ai 6 5 1

A_ai 7 1 3

A_ai 7 2 2

A_ai 7 3 2

A_ai 7 4 3

A_ai 7 5 1

A_ai 8 1 2

A_ai 8 2 2

A_ai 8 3 3

A_ai 8 4 4

A_ai 8 5 3

A_ai 9 1 2

A_ai 9 2 1

A_ai 9 3 1

A_ai 9 4 1

A_ai 9 5 2

A_ai 10 1 1

A_ai 10 2 2

A_ai 10 3 1

A_ai 10 4 1

A_ai 10 5 1

;

run;

proc transpose data=have out=want(drop=_name_) prefix=field_ ;by Tratamento repet;var field;

Frequent Contributor
Posts: 115

## Re: PROC TRANSPOSE Doubts and needing some clues

Posted in reply to Steelers_In_DC

Thanks  but it is what i did manually to explain the example.

Discussion stats
• 6 replies
• 284 views
• 1 like
• 3 in conversation