Help using Base SAS procedures

PROC REPORT and Moving a Value From a Numeric Field to a Character Field

Accepted Solution Solved
Reply
Contributor
Posts: 33
Accepted Solution

PROC REPORT and Moving a Value From a Numeric Field to a Character Field

[ Edited ]

I am trying to move a value from a numeric field column in the RBREAK summary line to a character field column in the RBREAK summary line.

 

I have a list of account numbers in a character field and I want to show the total number of accounts in the RBREAK summary line under list in the same character column as the account numbers. Here is an example where the number in bold is the total:

...

29487758

20447647

29223674

26185954

14,298

 

I have tried creating a dumby field that displays the integer 1 for each account and then aggregates for the total in the RBREAK line. How would I get that total into character format and moved to the RBREAK line under my list of accounts?

 

Here is some example code from the CLASS dataset in SAS with my attempt in red.

 

TITLE1 "List Report";

FOOTNOTE1 "Generated by the SAS System (&_SASSERVERNAME, &SYSSCPL) on %TRIM(%QSYSFUNC(DATE(), NLDATE20.)) at %TRIM(%SYSFUNC(TIME(), TIMEAMPM12.))";

proc format;

value blankValue other=' ';

run;

proc report data=WORK.QUERY_FOR_CLASS nowd out=exdata;

column Name Sex Age Height Weight N;

define Name / group 'Name' missing;

compute Name / char length=12;

if _break_ = '_RBREAK_' then Name = put(N.sum,4.);

/*if _break_='_RBREAK_' then do;

call define("N.SUM", 'format', '$6.');

end;*/

endcomp;

define Sex / group 'Sex' missing;

compute Sex;

if _break_ eq ' ' then do;

if Sex ne ' ' then hold2=Sex;

end;

endcomp;

define Age / analysis SUM 'Age' missing;

compute Age;

if _break_='_RBREAK_' then do;

call define("Age.SUM", 'format', 'blankValue.');

end;

endcomp;

define Height / analysis SUM 'Height' missing;

compute Height;

if _break_='_RBREAK_' then do;

call define("Height.SUM", 'format', 'blankValue.');

end;

endcomp;

define Weight / analysis SUM 'Weight' missing;

compute Weight;

if _break_='_RBREAK_' then do;

call define("Weight.SUM", 'format', 'blankValue.');

end;

endcomp;

define N / analysis SUM 'N' missing;

/*rbreak after / summarize;*/

compute after;

/*strg = "Total Accounts = " || trim(left(put(N.sum,5.2)));*/

count(Name);

line ' ';

endcomp;

run;

quit;

proc catalog catalog=work.formats;

delete blankvalue / entrytype=format;

run;TITLE; FOOTNOTE;

 

Thanks!

Nate


Accepted Solutions
Solution
‎11-07-2016 09:20 AM
Super User
Posts: 9,662

Re: PROC REPORT and Moving a Value From a Numeric Field to a Character Field


proc report data=sashelp.class nowd;
column sex name weight n;
define sex/order;
define n/noprint;
compute after;
 weight.sum=.;
 name=put(n,best8.);
endcomp;
rbreak after /summarize;
run;

View solution in original post


All Replies
Solution
‎11-07-2016 09:20 AM
Super User
Posts: 9,662

Re: PROC REPORT and Moving a Value From a Numeric Field to a Character Field


proc report data=sashelp.class nowd;
column sex name weight n;
define sex/order;
define n/noprint;
compute after;
 weight.sum=.;
 name=put(n,best8.);
endcomp;
rbreak after /summarize;
run;

Contributor
Posts: 33

Re: PROC REPORT and Moving a Value From a Numeric Field to a Character Field

Ksharp,

 

Thank you for the help, I could not quite get the code right to work.

 

Regards,

Nate

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 192 views
  • 0 likes
  • 2 in conversation