BookmarkSubscribeRSS Feed
rohitdante16
Fluorite | Level 6

using proc report i am trying to achive transposing the column description into a row grouped description

ie from

This is a test
Col 1Col 2
a1
b2

3

 

to 

 

This is a TestCol 1Col 2
a1
b2

3

 

is it possible as even if i define a dummy column the result is not as expected above.

8 REPLIES 8
Kurt_Bremser
Super User

Would you please post your source dataset in a data step with datalines?

Like

data have;
input col1 $ col2;
datalines;
a 1
b 2
c 3
;
run;

so we have a clear picture what you're working with.

rohitdante16
Fluorite | Level 6

yes thats it

. so normally if i give a proc report say

 

proc report data=have;

column ('This is a test' col1 col2);

define col1 / display 'Column 1' center style(column)=[vjust=m just=l];

define col2 / display 'Column 2' center style(column)=[vjust=m just=l];

run;

 

would give me the outcome like 

This is a test
Col 1Col 2
a1
b2
3

 

i would need the "This is a Test line" to span across rows and not across columns.

Please advice 

Thanks for the help in advance!!

Kurt_Bremser
Super User

Create an empty column for your label?

data have;
input col1 $ col2;
datalines;
a 1
b 2
c 3
;
run;

proc report data=have;
column empty col1 col2;
define empty / computed 'This is a test';
define col1 / display 'Column 1' center style(column)=[vjust=m just=l];
define col2 / display 'Column 2' center style(column)=[vjust=m just=l];
compute empty /character;
empty = " ";
endcomp;
run;
rohitdante16
Fluorite | Level 6

yes that would only add it as a new column but i would like for it be as a lable for the entire table

 a1This is a test Column 1 Column 2
 b2
 c3

 

not as above but as

 

 a1  Column 1 Column 2
This is a testb2
 c3

 

a merged single column for the entire table description

more like a book mark for the table hanging out

Ksharp
Super User

I don't catch your Q well .

This is you want ?

 

proc report data=have nowd spanrows;
PaigeMiller
Diamond | Level 26

Or this:

 

data have;
input test &$16. col1 $ col2;
datalines;
this is a test  a 1
this is a test  b 2
this is a test  c 3
;
run;

proc report data=have;
column test col1 col2;
define test / group format=$16. ' ';
define col1 / display 'Column 1' center style(column)=[vjust=m just=l];
define col2 / display 'Column 2' center style(column)=[vjust=m just=l];
run;

Of course, there isn't (as far as I know) a way in PROC REPORT to truly merge the cells (as there would be in Excel) to have the text "This is a text" span the three rows.

--
Paige Miller
rohitdante16
Fluorite | Level 6

Thanks team much need confirmation as well, since i tried using Spanrows and every possible permutation and combination in the SAS book for this confirmation , let me justify the same to my business.

Tom
Super User Tom
Super User

I think this is what you want to do. 

proc report data=have spanrows;
column group col1 col2;
define group /  group ' ';
run;

image.png

If so you need to add the variable to the data BEFORE the proc report step.

You could use a view if you want.

data have;
input col1 $ col2;
datalines;
a 1
b 2
c 3
;
run;

data for_report / view=for_report ;
  set have;
  group='This is a test';
run;
proc report data=for_report spanrows;
  column group col1 col2;
  define _all_ / display;
  define group /  order ' ';
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 8 replies
  • 991 views
  • 1 like
  • 5 in conversation