using proc report i am trying to achive transposing the column description into a row grouped description
ie from
This is a test | |
Col 1 | Col 2 |
a | 1 |
b | 2 |
c | 3 |
to
This is a Test | Col 1 | Col 2 |
a | 1 | |
b | 2 | |
c | 3 |
is it possible as even if i define a dummy column the result is not as expected above.
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.
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 1 | Col 2 |
a | 1 |
b | 2 |
c | 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!!
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;
yes that would only add it as a new column but i would like for it be as a lable for the entire table
b | 2 | |
c | 3 |
not as above but as
This is a test | b | 2 |
c | 3 |
a merged single column for the entire table description
more like a book mark for the table hanging out
I don't catch your Q well .
This is you want ?
proc report data=have nowd spanrows;
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.
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.
I think this is what you want to do.
proc report data=have spanrows;
column group col1 col2;
define group / group ' ';
run;
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;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.