Help using Base SAS procedures

PROC TRANSPOSE Doubts and needing some clues

Reply
Frequent Contributor
Posts: 103

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=_Smiley Happy;

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: 11,343

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: 103

Re: PROC TRANSPOSE Doubts and needing some clues

Thanks you very much and Excelent:

im obtaining this:

1A_ai11.
2A_ai12.
3A_ai13.
4A_ai14.
5A_ai15.
6A_ai21.
7A_ai22.
8A_ai23.
9A_ai24.
10A_ai25.
11A_ai31.
12A_ai32.
13A_ai33.
14A_ai34.
15A_ai35.
16A_ai41.
17A_ai42.
18A_ai43.
19A_ai44.
20A_ai45.
21A_ai51.
22A_ai52.
23A_ai53.
24A_ai54.
25A_ai55.
26A_ai61.
27A_ai62.
28A_ai63.
29A_ai64.
30A_ai65.
31A_ai71.
32A_ai72.
33A_ai73.
34A_ai74.
35A_ai75.
36A_ai81.
37A_ai82.
38A_ai83.
39A_ai84.
40A_ai85.
41A_ai91.
42A_ai92.
43A_ai93.
44A_ai94.
45A_ai95.
46A_ai101.
47A_ai102.
48A_ai103.
49A_ai104.
50A_ai105.

just points

Thanks one more time

Frequent Contributor
Posts: 103

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: 11,343

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: 860

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: 103

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.

Ask a Question
Discussion stats
  • 6 replies
  • 270 views
  • 1 like
  • 3 in conversation