The SAS Output Delivery System and reporting techniques

proc report help

Reply
Occasional Contributor
Posts: 7

proc report help


Hello everybody!

I have a problem. I have that data step:


DATA test;
   INPUT kw id  A1 A2 ;
   DATALINES;
34 50012127 1 6
34 50012128 4 3
34 50012129 1 1
35 50012127 2 7
35 50012128 5 1
35 50012129 2 2
36 50012127 3 8
36 50012128 3 2
36 50012129 23 3
37 50012127 4 9
37 50012128 6 2
37 50012129 3 3
38 50012127 5 10
38 50012128 9 2
38 50012129 2 3

;
Run;

How can I bulid or find under the table with the Proc report:

IDKW
3435363738
50012127  A112345
A2678910
50012128  A145369
A231222
50012129   A1122332
A212333
50012125  A112364
A212365
50012122  A1123645
A21233

thanks,
Celal

Contributor
Posts: 72

Re: proc report help

My SAS is busy so I'm unable to create code and test but you could PROC SORT by id, A1, A2 and then PROC TRANSPOSE to make your long table wide like your example and then it would make the PROC REPORT easier to code.

Occasional Contributor
Posts: 7

Re: proc report help

without ID i can build that table with PROC TRANSPOSE but i need also ID.

i use the Proc Report:


proc report nowd data=test

col id (kw,(A1 A2));
define id /group ;
define kw / across ;
define A1 /sum ;
define A2 /sum  ;
run;

Here I think this problem is column. I playing with column but i didn't find a solution.

SAS Super FREQ
Posts: 8,743

Re: proc report help

Hi:

  If you have a variable that contained either 'A1' or 'A2' as the value and restructured your data a bit, PROC REPORT can give you the report you want. Screenshot produced with this code.

cynthia

DATA newtest;

   ** read KW and ID vars.;

   ** then hold input line;

   ** in order to write 2 obs out for every;

   ** dataline that is read in.;

   INPUT kw id @;

  

   ** create type for A1;

   ** read val as numeric;

   type = 'A1';

   input val @;

   output;

  

   ** create type for A2;

   ** read val as numeric;

   type = 'A2';

   input val;

   output;

   DATALINES;

34 50012127 1 6

34 50012128 4 3

34 50012129 1 1

35 50012127 2 7

35 50012128 5 1

35 50012129 2 2

36 50012127 3 8

36 50012128 3 2

36 50012129 23 3

37 50012127 4 9

37 50012128 6 2

37 50012129 3 3

38 50012127 5 10

38 50012128 9 2

38 50012129 2 3

;

Run;

  

ods html file='c:\temp\restructure_report.html';

     

proc print data=newtest;

  title 'What is data';

run;

       

proc report data=newtest nowd;

  title 'Proc REPORT with ACROSS';

  column ('ID' id) ('Type' type) kw,val;

  define id / group ' ';

  define type / group ' ';

  define kw / across;

  define val / sum ' ';

run;

ods _all_ close;


restructure_report.png
Occasional Contributor
Posts: 7

Re: proc report help

Great!, thanks a lot

Celal

Ask a Question
Discussion stats
  • 4 replies
  • 310 views
  • 0 likes
  • 3 in conversation