BookmarkSubscribeRSS Feed
jonatan_velarde
Pyrite | Level 9

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

6 REPLIES 6
ballardw
Super User

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;

jonatan_velarde
Pyrite | Level 9

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

jonatan_velarde
Pyrite | Level 9

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!!

ballardw
Super User

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

Steelers_In_DC
Barite | Level 11

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;

jonatan_velarde
Pyrite | Level 9

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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