BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have been trying to format my data so it looks like the below example.

Total Customer Count..........47
Total Amount...............$465.00

I've had no luck, nor can I find/figure out how to get it to look how I want. Any suggestions?
4 REPLIES 4
Cynthia_sas
SAS Super FREQ
Hi:
This is almost impossible to answer unless we have a bit more information:
-- what procedure or code are you using to create your output?
-- what destination (ODS HTML, LISTING, ODS RTF, ODS PDF) are you using for the output?
-- what does your data set look like? Show some sample data -- for example are these two rows of information coming from a summary procedure (like PROC MEANS or PROC TABULATE??) How do you get these numbers?
-- Are your variables in the second column (the 47 and 465.00) character or numeric variables? Most SAS procedures would want the same numeric format to be used for one column. But, if you were using PROC REPORT, for example, you -could- format the number in one row to have no decimal places and the number in a different row to have 2 decimal places - -but this is not possible with many other procedures.

For more information about how to post code or data to the forum, refer to this posting: http://support.sas.com/forums/thread.jspa?threadID=7550

cynthia
deleted_user
Not applicable
Sorry for the lack of information.

I am using proc report and the destination is ODS PDF. I was trying to get the totalpct and endcnt to look like what I posted earlier.

options nodate nonumber;
ods pdf file="C:\PC_SAS\TEST FORMATTING.pdf";
ods escapechar='^';

proc report data=CanxPctCnt nowd split='#' center;
title
j=c '^S={preimage="D:\Documents and Settings\amrapon\Desktop\Harley Quinn Report\Quinn Logo For Top Of Report.jpg"}'
j=c 'Dealer: 0415';
footnote1 j=r 'Page ^{thispage} of ^{lastpage}';
column Brand2 EndStatus RptMthC , (endcnt TotalPct);
define Brand2 / group order=internal width=8 format=$4.;
define EndStatus / group order=internal width=8 format=$4.;
define RptMthC / group order=data across " ";
define endcnt /group " ";
define TotalPct / sum format=percent7.1 " " ;
run;
ods _all_ close;
ods listing;
Cynthia_sas
SAS Super FREQ
Hi:
I am having a problem envisioning what your data looks like. This usage of RptMthC in the column statement:
column Brand2 EndStatus RptMthC , (endcnt TotalPct) ;

with RptMthC,(endcnt TotalPct) would normally indicate that you wanted RptMthC to be an ACROSS usage. Generally, you have numeric variables -under- ACROSS variables ...so I would have expected endcnt and TotalPct to be either DISPLAY usage or SUM, MEAN or some other ANALYSIS usage. Instead I notice that you have endcnt as a GROUP usage and TotalPct as a SUM usage. I would expect that while this might not give you errors in the PROC REPORT step, it also might not look the way you desire.

However, when I run some test data using code based on your original code, I see that ENDCNT is right justified (assuming it is numeric) and that TOTALPCT has a percent sign and is also right justified in the cell. In my fake data, ENDCNT is NUMERIC and TOTALPCT is numeric and RPTMTHC is a CHARACTER variable, as shown below. Can you show a sample of the data you're working with???

cynthia

[pre]
data canxpctcnt;
length brand2 $4 endstatus $4 rptmthc $1;
infile datalines;
input brand2 $ endstatus $ rptmthc $ endcnt TotalPct;
** totalpct = 10/120 just to make up a number;
return;
datalines;
AAAA 1111 1 10 0.08333
AAAA 1111 2 10 0.08333
AAAA 1111 3 10 0.08333
AAAA 1111 4 10 0.08333
AAAA 1111 5 10 0.08333
AAAA 1111 6 10 0.08333
AAAA 2222 1 10 0.08333
AAAA 2222 2 10 0.08333
AAAA 2222 3 10 0.08333
AAAA 2222 4 10 0.08333
AAAA 2222 5 10 0.08333
AAAA 2222 6 10 0.08333
BBBB 1111 1 10 0.08333
BBBB 1111 2 10 0.08333
BBBB 1111 3 10 0.08333
BBBB 1111 4 10 0.08333
BBBB 1111 5 10 0.08333
BBBB 1111 6 10 0.08333
BBBB 2222 1 10 0.08333
BBBB 2222 2 10 0.08333
BBBB 2222 3 10 0.08333
BBBB 2222 4 10 0.08333
BBBB 2222 5 10 0.08333
BBBB 2222 6 10 0.08333
run;

ods listing close;
options nodate nonumber orientation=landscape;
ods pdf file="C:\temp\TEST_FORMATTING.pdf";

proc report data=CanxPctCnt nowd split='#' center;
column Brand2 EndStatus RptMthC , (endcnt TotalPct) ;
define Brand2 / group order=internal width=8 format=$4.;
define EndStatus / group order=internal width=8 format=$4.;
define RptMthC / across order=data across "rptmthc";
define endcnt /sum "endcnt";
define TotalPct / sum format=percent10.1 "totalpct" ;
run;
ods _all_ close;
ods listing;

[/pre]
deleted_user
Not applicable
Have you thought about using logic to combine the text and numbers you need into a single variable? Then your Proc Report would display that variable. You might need to also create a sequence variable to insure your lines display in the correct order.

For example:

If your dataset contained two variables: cnt and amt, the code might look like this:

data rpt;
set cust;
length seq 8. text $40. cnt_x amt_x $10.;

/* Generate Customer Count Variable */
seq = 1;
cnt_x = strip(put(cnt,3.)); /* Format and Move Count to character Var */
len_cnt = length(cnt_x); /* Determine the Length of the Count Var */
text = 'Total Customer Count';
len_text = length(text); /* Determine the Length of the Text Var */
num_per = 40-(len_text+len_cnt); /* Calculate the number of Periods */
text = strip(text) || repeat('.',num_per-1) || strip(cnt_x); /* Build the Text Var */
output;

/* Generate Total Amount Variable */
seq = 2;
amt_x = strip(put(amt,dollar10.2));
len_amt = length(amt_x);
text = 'Total Amount';
len_text = length(text);
num_per = 40-(len_text+len_amt);
text = strip(text) || repeat('.',num_per-1) || strip(amt_x);
output;
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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