BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
elsfy
Quartz | Level 8

Hi,

 

Doing a proc report i have some issues regarding the format of my output.

 

So i did this but this is not exactly what i want : 

proc report data = a ; 

column ( '^{style[color=red]Date}' ('Category of the product sold before the month' '^{style[color=red]Company n°1784}' var1 var2 ... ; 
... ; 
run ; 

isgnr_0-1652099754769.png

Here "Company n°1784" is like a subheader of "Category of [...] month" but what i want is to display "Company n°1784" below "Category of [...] month" but recognized in the same header in order to have this excel output : 

 

isgnr_2-1652100026669.png

 

So this was the first part of the problem.

 

Now, after that, i have another issue when exporting the output on an excel worksheet.

Instead of displaying the header as shown above, it displays it like that on excel: 

isgnr_3-1652100136575.png


(Yet, it is displayed correctly on the SAS report).

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  When I run your code with some fake data, the headers have some odd placement; but the header seems to be colored as you want

Cynthia_sas_1-1652212343844.png

I used this code running on a Windows system with 9.4M7:

Cynthia_sas_2-1652212495411.png

 If you want your spanning header for Company n°1784 to be in the blank box, then I think you need to move one of your ending parentheses so it is after pct_tot.

  When I altered the column statement to move just one of the ending parentheses, I got these results:

Cynthia_sas_3-1652213024337.png

Cynthia

 

View solution in original post

7 REPLIES 7
Ksharp
Super User

Why not put it all together and using split char ?

Or @Cynthia_sas  could give you right answer.

 

proc report split='/' 

('Category of the product sold before the month / ^{style[color=red]Company n°1784}'
elsfy
Quartz | Level 8

Hi,
Thank you, now "Company n°1784" is under the other text.

Do you know why it's not in red ? The code you shared is not putting "Company n°1784" in red.

Also, i still have this problem below :

isgnr_0-1652175447685.png

 

 

Cynthia_sas
SAS Super FREQ
Hi:
In order to provide any suggestions, I would need to see more than 2 snippets of code in order to make suggestions. For example, ALL of the PROC REPORT code, including the column statement, define statements and any compute blocks. And, also useful would be the ODS statements showing which destination is being used for the Excel file. In addition, having some context or picture of the entire report (not just 1 header) would be useful.
Cynthia
elsfy
Quartz | Level 8

Hi, 

Hope this code helps. This is what i've done : 

 

title color=red bcolor=red "xxxx" ; 
ods excel file = "..../file.xlsx"
options(sheet_interval='none' embedded_titles='yes' start_at='1,2' hidden_rows = '2') ;
ods listing;
ods escapechar = '^' ;
options missing=0 orientation=landscape center;
proc report data = a split ='-' nowd headskip center
style(header)={background=white borderwidth=1 bordercolor=black width=150 color=black just=c textalign=c}
style(report)={borderwidth=1 bordercolor=black outputwidth=150 just=c}
style(column)= {borderwidth=1 bordercolor=black just=r color=black tagattr='format:###,###,###,###,###0'}
style(summary)= [just=c textalign=c];
column ('^{style[color=red] Reporting}' ('Category of the product (sold before the date) - ^{style[color=red] Company n°1784}' var1 var2 var3 var4 var5 pct_tot
('Category of the product (sold before the date) - ^{style[color=red] Company n°2001}' var4 var5 pct_tot))
) ; define var1 / group width=132;
define var2 / group ;
define var3 / group ;
define var4 / analysis sum '...€' style(column)=[borderrightwidth=2 borderrightcolor=black];
define var5 / analysis sum '...€' ;
define pct_tot / computed style(column) = [tagattr = "format:#0.%"] ;
rbreak after / summarize style(summary) = {font_weight=bold background=lightgrey just=r} ;

compute pct_tot ;
pct_tot = var4.sum/var5.sum ;
endcomp ; run ;

This is what i get : 

isgnr_0-1652187158297.png

Replacing the split symbol "/" with "-" helped me to get all the text ("Category [...] date)") on the same line

 

Now the only problem left is that i want "Company n°...." in red. Since it isn't a defined column i can't change it's style in the define statement (from what i know).

PS:I am sorry if the code isn't very clear, i can't share everything due to confidentiality.

Cynthia_sas
SAS Super FREQ

Hi:

  It's too bad you can't make some fake data to illustrate the issue. Without data, it's hard to make constructive suggestions. I've formatted your code and highlighted some inconsistencies:

Cynthia_sas_0-1652189602755.png

You are mixing LISTING only options with ODS Style overrides. None of your ODS overrides for width have a unit of measure. It's not clear to me what the  structure of your data is or why you're repeating var4, var5 and pct_tot in the column statement but with different headers. I don't see how the values will be different.

Cynthia

elsfy
Quartz | Level 8
" It's not clear to me what the structure of your data is or why you're repeating var4, var5 and pct_tot in the column statement but with different headers. I don't see how the values will be different."

Actually, i forgot to edit this part of the code. They are not supposed to be repeated variables but others variables which could be var6, var7, pct_tot2 (also defined in the DEFINE statement).

Is all the code required to understand why can't i color a part of my header in red ?
Cynthia_sas
SAS Super FREQ

Hi:

  When I run your code with some fake data, the headers have some odd placement; but the header seems to be colored as you want

Cynthia_sas_1-1652212343844.png

I used this code running on a Windows system with 9.4M7:

Cynthia_sas_2-1652212495411.png

 If you want your spanning header for Company n°1784 to be in the blank box, then I think you need to move one of your ending parentheses so it is after pct_tot.

  When I altered the column statement to move just one of the ending parentheses, I got these results:

Cynthia_sas_3-1652213024337.png

Cynthia

 

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!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 7 replies
  • 1693 views
  • 2 likes
  • 3 in conversation