BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rajesh1980
Obsidian | Level 7

Hi,

 

I am creating a ODS Excel PROC REPORT where i have a attribute column which is displayed across along with a metric column to display the metric. The attribute column has revenue figures as well as other KPIs. The revenue figures i want them to be formatted with a $ symbol and the other KPIs as normal. 

 

This is the code i have , the CHARGE_TEXT field is the KPI column and CHARGE is metric column. 

 

Im using a COMPUTE CHARGE_TEXT block to try and add a conditional tagattr, but it is not working.i am attaching the code and output.KIndly help with my ask.

proc report data=BASE_UNBUND_REV_ELEC_12M_MOD nowd spanrows missing
style(report)=[bordercolor=black borderwidth=3pt]
style(header)=[verticalalign=middle backgroundcolor=cx4C7DC4 foreground=white]
style(summary)=[backgroundcolor=black foreground=white fontstyle=roman fontweight=bold bordercolor=black borderwidth=2pt]
;
	by pucgrp;
	
	column pucgrp ratelit ('Rate Literal' ratelit_disp) consumption_dt ('Year' consumption_yr_disp)  ('Month' consumption_dt_disp) (charge_text, (charge));

	define pucgrp / '' group noprint;

	define ratelit / '' group noprint;
	define ratelit_disp / '' computed style(column)=[backgroundcolor=lightgrey];

	define consumption_dt / order=internal group '' noprint;
	define consumption_yr_disp / f=year4. '' computed style(column)=[backgroundcolor=lightgrey];
	define consumption_dt_disp / f=monname3. '' computed style(column)=[backgroundcolor=lightgrey];

	define charge_text / across order=data '' style(column)=[backgroundcolor = white width=40%] ;
	define charge / '' style(column)=[backgroundcolor = white] ;
	
	compute before ratelit;
		hold_ratelit = ratelit;
	endcomp;

	compute before consumption_dt;
		hold_consumption_dt = consumption_dt;
	endcomp;


	compute ratelit_disp / char length=25;
		ratelit_disp = hold_ratelit;
	endcomp;

	compute consumption_yr_disp;
		consumption_yr_disp = hold_consumption_dt; 
	endcomp;

	compute consumption_dt_disp;
		consumption_dt_disp = hold_consumption_dt; 
	endcomp;
	
	compute charge_text;
		if charge_text = 'Billed Months' then 
			do;
				call define('charge','style','style={tagattr="0.00,[Red](0.00),0.00"}');
			end;
		else;
			do;
				call define('charge','style','style={tagattr="$0.00,[Red]($0.00),$0.00"}');
			end;
	endcomp;
	
	compute after ratelit;
		call define ('consumption_yr_disp', 'style', 'style=[tagattr=''formula:=""'']');
		call define ('consumption_dt_disp', 'style', 'style=[tagattr=''formula:=""'']');
	endcomp;
	break after ratelit / summarize; /* Every time the ratelit Changes Summarize the table (SubTotal)*/

run;

This is output im getting. Wherever i have pointed out with the arrow i need to be displayed as style={tagattr="0.00,[Red](0.00),0.00"} and all others as style={tagattr="$0.00,[Red]($0.00),$0.00"}

 

rajesh1980_0-1607500770525.png

 

this is how my data looks

PUCGRPRATELITCONSUMPTION_DTIDCHARGE_TEXTCHARGE
DomesticD-CARE-SDP-O/BUND01Jul20200Billed Months1.50
DomesticD-CARE-SDP-O/BUND01Jul20200Billed KWH5013.97
DomesticD-CARE-SDP-O/BUND01Jul20200Billed Operating Revenue777.39
DomesticD-CARE-SDP-O/BUND01Jul20201Generation (Post)506.27
DomesticD-CARE-SDP-O/BUND01Jul20202GTSR Charge0.00
DomesticD-CARE-SDP-O/BUND01Jul20203GTSR Credit0.00
DomesticD-CARE-SDP-O/BUND01Jul20204GTSR Indifference Adj0.00
DomesticD-CARE-SDP-O/BUND01Jul20205PTR/SEP Fixed Capacity Cr-G0.00
DomesticD-CARE-SDP-O/BUND01Aug20200Billed Months1.23
DomesticD-CARE-SDP-O/BUND01Aug20200Billed KWH2382.29
DomesticD-CARE-SDP-O/BUND01Aug20200Billed Operating Revenue358.22
DomesticD-CARE-SDP-O/BUND01Aug20201Generation (Post)334.46
DomesticD-CARE-SDP-O/BUND01Aug20202GTSR Charge0.00
DomesticD-CARE-SDP-O/BUND01Aug20203GTSR Credit0.00
DomesticD-CARE-SDP-O/BUND01Aug20204GTSR Indifference Adj0.00
DomesticD-CARE-SDP-O/BUND01Aug20205PTR/SEP Fixed Capacity Cr-G0.00
DomesticD-CARE-SDP-O/BUND01Sep20200Billed Months1.77
DomesticD-CARE-SDP-O/BUND01Sep20200Billed KWH1108.08
DomesticD-CARE-SDP-O/BUND01Sep20200Billed Operating Revenue119.81
DomesticD-CARE-SDP-O/BUND01Sep20201Generation (Post)143.42
DomesticD-CARE-SDP-O/BUND01Sep20202GTSR Charge0.00
DomesticD-CARE-SDP-O/BUND01Sep20203GTSR Credit0.00
DomesticD-CARE-SDP-O/BUND01Sep20204GTSR Indifference Adj0.00
DomesticD-CARE-SDP-O/BUND01Sep20205PTR/SEP Fixed Capacity Cr-G0.00
DomesticD-CARE-SDP-O/BUND01Oct20200Billed Months0.50
DomesticD-CARE-SDP-O/BUND01Oct20200Billed KWH276.67
DomesticD-CARE-SDP-O/BUND01Oct20200Billed Operating Revenue28.63
DomesticD-CARE-SDP-O/BUND01Oct20201Generation (Post)24.71
DomesticD-CARE-SDP-O/BUND01Oct20202GTSR Charge0.00
DomesticD-CARE-SDP-O/BUND01Oct20203GTSR Credit0.00
DomesticD-CARE-SDP-O/BUND01Oct20204GTSR Indifference Adj0.00
DomesticD-CARE-SDP-O/BUND01Oct20205PTR/SEP Fixed Capacity Cr-G0.00

 

1 ACCEPTED SOLUTION

Accepted Solutions
rajesh1980
Obsidian | Level 7

@Cynthia_sas Thank you Ma'am. It worked!

 

I used 

 

	compute charge_text;
		call define('_c7_','style','style={tagattr="0.00,[Red](0.00),0"}');
		call define('_c8_','style','style={tagattr="0.00,[Red](0.00),0"}');
	endcomp;

One thing i learned today is that the column numbers are based on the definition in the column statement. I was trying c4 and c5 it wasnt working then by trial and error i found out it was c7 and c8

 

that is because the column statement is defined as 

 

	column pucgrp ratelit ('Rate Literal' ratelit_disp) consumption_dt ('Year' consumption_yr_disp)  ('Month' consumption_dt_disp) (charge_text, (charge));

so charge_text is C7. 

 

View solution in original post

2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi:
With ACROSS items and especially when you have nested a numeric value under the ACROSS item, you cannot change anything in a CALL DEFINE by using the variable name, as you show. You must either use absolute column numbers, as explained in this paper: https://support.sas.com/resources/papers/proceedings14/SAS388-2014.pdf

Look at the example specifically that starts on page 9 and the CALL DEFINE example that is on page 11.

Cynthia
rajesh1980
Obsidian | Level 7

@Cynthia_sas Thank you Ma'am. It worked!

 

I used 

 

	compute charge_text;
		call define('_c7_','style','style={tagattr="0.00,[Red](0.00),0"}');
		call define('_c8_','style','style={tagattr="0.00,[Red](0.00),0"}');
	endcomp;

One thing i learned today is that the column numbers are based on the definition in the column statement. I was trying c4 and c5 it wasnt working then by trial and error i found out it was c7 and c8

 

that is because the column statement is defined as 

 

	column pucgrp ratelit ('Rate Literal' ratelit_disp) consumption_dt ('Year' consumption_yr_disp)  ('Month' consumption_dt_disp) (charge_text, (charge));

so charge_text is C7. 

 

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
  • 2 replies
  • 1933 views
  • 0 likes
  • 2 in conversation