SAS_Experts:
To prepare many, many reports of the following general structure:
Health Factor
Revision State GON1 SYPH1 HSV1 CHAM1
HEPB1 HEPC1
____________________________________________________________________________
_______________________________________________
Unrevised Alabama 0 0 0 0
0 0
Alaska 0 0 0 0
0 0
Arizona 0 0 0 0
0 0
Arkansas 0 0 0 0
0 0
California 0 0 0 0
0 0
..
..
Next page
Mid-Year Vermont 0 0 0 0
0 0
Revised Florida 1 1 1 1
1 1
Idaho 1 1 1 1
1 1
Possessions Puerto Rico 1 1 1 1
1 1
Virgin Islands 0 0 0 0
0 0
Guam 0 0 0 0
0 0
..
..
The following statements did the trick
PROC FORMAT;
VALUE FlagIdName
1 = '1 Unrevised'
2 = '2 Mid-Year'
3 = '3 Revised'
4 = '4 Possessions';
run;
OPTIONS NODATE NOCENTER MLOGIC SYMBOLGEN MPRINT NONUMBER PS=45 LS=225;
DATA Output;
SET UnRevised MidYearRevised RevisedOnly Possessions END = EOF;
by FLAGINDEX;
TITLE;
Do KF = 1 to 4;
If kf = 1 and First.FLAGINDEX=1 then
put @1 FLAGINDEX FlagIdName.
@15 ST_NAME $21.
@38 IP_GON1 $1.
@47 IP_SYPH1 $1.
@56 IP_HSV1 $1.
@65 IP_CHAM1 $1.
@74 IP_HEPB1 $1.
@83 IP_HEPC1 $1.
;
ELSE
If kf = 1 and First.FLAGINDEX NE 1 then
put
@15 ST_NAME $21.
@38 IP_GON1 $1.
@47 IP_SYPH1 $1.
@56 IP_HSV1 $1.
@65 IP_CHAM1 $1.
@74 IP_HEPB1 $1.
@83 IP_HEPC1 $1.
;
IF EOF THEN PUT
"_________________________________________________________________________
____________________________________________________________________________
____________________";
RETURN;
HEADNOTE:
tday=date();
PUT @46 &thisyear ' Natality Flag File Report' @161 tday date7. /
@52 'Revised Infections ' //
'Revision State IPGON1 IPSYPH1 IPHSV1 IPCHAM1
IPHEPB1 IPHEPC1'/
"___________________________________________________________________________
____________________________________________________________________________
__________________";
Return;
end;
RUN;
To apply this to 30+ other reports primarily varying in columns the PROC
REPORT Macro was written.It does the trick with the small exceptions below:
(Some columns were removed from this screen)
%MACRO NatFlags6(Title=, X1=,X2= ,X3= ,X4= ,X5= ,X6= );
PROC REPORT nowindows
DATA = output;
COLUMN
FLAGINDEX
ST_NAME
&X1
&X2
&X3
&X4
&X5
&X6;
DEFINE FLAGINDEX /ORDER FORMAT = FlagIdName. Left Width =12 ;
DEFINE ST_NAME /DISPLAY ;
DEFINE &X1 /FORMAT= $1. Width =8 "&X1" ;
DEFINE &X2 /FORMAT= $1. Width =8 "&X2" ;
DEFINE &X3 /FORMAT= $1. Width =8 "&X3" ;
DEFINE &X4 /FORMAT= $1. Width =8 "&X4" ;
DEFINE &X5 /FORMAT= $1. Width =8 "&X5" ;
DEFINE &X6 /FORMAT= $1. Width =8 "&X6" ;
TITLE1"
&thisyear NATALITY FLAG FILE
REPORT %
sysfunc(date(), date7.)";
TITLE2" ";
TITLE3"
&Title";
TITLE4"_____________________________________________________________
____________________________________________________________________________
________________________";
%MEND NatFlags6;
*REPORT 20 REVISED FACTORS;
%NatFlags6 (Title =10 REVISED FACTORS, X1= IP_GON1, X2=LD_AUGL1, X3=
IP_SYPH1, X4 =IP_CHAM1, X5 = IP_HEPB1, X6= IP_HEPC1);
run;
OUTPUT
2005 FLAG FILE
REPORT
15AUG07
20 REVISED FACTORS
____________________________________________________________________________
_________________________________________________________________
FLAGINDEX ST_NAME GON1 AUGL1 SYPH1
1 Unrevised Alabama 0 0 0
Alaska 0 0 0
Arizona 0 0 0
Arkansas 0 0 0
California 0 0 0
NEW PAGE for groups 2 3 AND 4.
..
..
2 Mid-Year Vermont 0 0 0
3 Revised Florida 1 1 1
Idaho 1 1 1
4 Possession Puerto Rico 1 1 1
Virgin Islands 0 0 0
Question 1. I had to add ( 1 , 2 3 4 to the name for correct grouping.
Customer had no objection until all was done. States need to be grouped
into Unrevised, Mid-year, Revised, Possession which are not descending.
Dataset OUTPUT has the correct data order. Proc REPORT seems to sort things
alphabetically. FlagIndex is a numeric dummy variable for unrevised, mid-
year, revised, possession, to be sorted and renamed with format when
ordered correctly.
How can the desired order be obtained in Proc Report with data that is in
the correct group order to start?
2. How can the title flagindex column title be removed or changed
to "revision" inside proc report. Renaming FlagIndex outside Proc report
will do it but it's not preferable.
3. I would like to add a single blank line ant the end of each group. The
proc report command used did more than this simple task.
TIA,
John
Pleases send a CC to caraj@cox.net
|
|
0
|
|
|
|
Reply
|
zbq5 (66)
|
8/15/2007 9:14:27 PM |
|
I have a hard time following all your code and output.
When using PROC REPORT, I find that NOPRINT is my best friend. You
can create all sorts or order variables to "correctly" order the rows
of the report and define them NOPRINT. See if doing the same in your
program gets you the desired output.
Most of my PROC REPORTS have more noprint variables than variables
that are actually displayed.
On 8/15/07, John Birken <zbq5@cdc.gov> wrote:
> SAS_Experts:
>
> To prepare many, many reports of the following general structure:
> Health Factor
>
> Revision State GON1 SYPH1 HSV1 CHAM1
> HEPB1 HEPC1
> ____________________________________________________________________________
> _______________________________________________
> Unrevised Alabama 0 0 0 0
> 0 0
> Alaska 0 0 0 0
> 0 0
> Arizona 0 0 0 0
> 0 0
> Arkansas 0 0 0 0
> 0 0
> California 0 0 0 0
> 0 0
> .
> .
> Next page
>
> Mid-Year Vermont 0 0 0 0
> 0 0
> Revised Florida 1 1 1 1
> 1 1
> Idaho 1 1 1 1
> 1 1
> Possessions Puerto Rico 1 1 1 1
> 1 1
> Virgin Islands 0 0 0 0
> 0 0
> Guam 0 0 0 0
> 0 0
> .
> .
>
> The following statements did the trick
>
> PROC FORMAT;
> VALUE FlagIdName
> 1 = '1 Unrevised'
> 2 = '2 Mid-Year'
> 3 = '3 Revised'
> 4 = '4 Possessions';
> run;
>
> OPTIONS NODATE NOCENTER MLOGIC SYMBOLGEN MPRINT NONUMBER PS=45 LS=225;
> DATA Output;
> SET UnRevised MidYearRevised RevisedOnly Possessions END = EOF;
> by FLAGINDEX;
> TITLE;
> Do KF = 1 to 4;
> If kf = 1 and First.FLAGINDEX=1 then
> put @1 FLAGINDEX FlagIdName.
> @15 ST_NAME $21.
> @38 IP_GON1 $1.
> @47 IP_SYPH1 $1.
> @56 IP_HSV1 $1.
> @65 IP_CHAM1 $1.
> @74 IP_HEPB1 $1.
> @83 IP_HEPC1 $1.
> ;
> ELSE
> If kf = 1 and First.FLAGINDEX NE 1 then
> put
> @15 ST_NAME $21.
> @38 IP_GON1 $1.
> @47 IP_SYPH1 $1.
> @56 IP_HSV1 $1.
> @65 IP_CHAM1 $1.
> @74 IP_HEPB1 $1.
> @83 IP_HEPC1 $1.
> ;
> IF EOF THEN PUT
> "_________________________________________________________________________
> ____________________________________________________________________________
> ____________________";
> RETURN;
>
> HEADNOTE:
> tday=date();
> PUT @46 &thisyear ' Natality Flag File Report' @161 tday date7. /
> @52 'Revised Infections ' //
> 'Revision State IPGON1 IPSYPH1 IPHSV1 IPCHAM1
> IPHEPB1 IPHEPC1'/
> "___________________________________________________________________________
> ____________________________________________________________________________
> __________________";
> Return;
> end;
> RUN;
>
> To apply this to 30+ other reports primarily varying in columns the PROC
> REPORT Macro was written.It does the trick with the small exceptions below:
> (Some columns were removed from this screen)
>
> %MACRO NatFlags6(Title=, X1=,X2= ,X3= ,X4= ,X5= ,X6= );
> PROC REPORT nowindows
> DATA = output;
> COLUMN
> FLAGINDEX
> ST_NAME
> &X1
> &X2
> &X3
> &X4
> &X5
> &X6;
> DEFINE FLAGINDEX /ORDER FORMAT = FlagIdName. Left Width =12 ;
> DEFINE ST_NAME /DISPLAY ;
> DEFINE &X1 /FORMAT= $1. Width =8 "&X1" ;
> DEFINE &X2 /FORMAT= $1. Width =8 "&X2" ;
> DEFINE &X3 /FORMAT= $1. Width =8 "&X3" ;
> DEFINE &X4 /FORMAT= $1. Width =8 "&X4" ;
> DEFINE &X5 /FORMAT= $1. Width =8 "&X5" ;
> DEFINE &X6 /FORMAT= $1. Width =8 "&X6" ;
>
> TITLE1"
> &thisyear NATALITY FLAG FILE
> REPORT %
> sysfunc(date(), date7.)";
> TITLE2" ";
> TITLE3"
> &Title";
> TITLE4"_____________________________________________________________
> ____________________________________________________________________________
> ________________________";
> %MEND NatFlags6;
>
> *REPORT 20 REVISED FACTORS;
> %NatFlags6 (Title =10 REVISED FACTORS, X1= IP_GON1, X2=LD_AUGL1, X3=
> IP_SYPH1, X4 =IP_CHAM1, X5 = IP_HEPB1, X6= IP_HEPC1);
> run;
>
> OUTPUT
>
> 2005 FLAG FILE
> REPORT
> 15AUG07
>
> 20 REVISED FACTORS
> ____________________________________________________________________________
> _________________________________________________________________
>
> FLAGINDEX ST_NAME GON1 AUGL1 SYPH1
> 1 Unrevised Alabama 0 0 0
> Alaska 0 0 0
> Arizona 0 0 0
> Arkansas 0 0 0
> California 0 0 0
>
> NEW PAGE for groups 2 3 AND 4.
> .
> .
> 2 Mid-Year Vermont 0 0 0
> 3 Revised Florida 1 1 1
> Idaho 1 1 1
> 4 Possession Puerto Rico 1 1 1
> Virgin Islands 0 0 0
>
>
>
>
> Question 1. I had to add ( 1 , 2 3 4 to the name for correct grouping.
> Customer had no objection until all was done. States need to be grouped
> into Unrevised, Mid-year, Revised, Possession which are not descending.
> Dataset OUTPUT has the correct data order. Proc REPORT seems to sort things
> alphabetically. FlagIndex is a numeric dummy variable for unrevised, mid-
> year, revised, possession, to be sorted and renamed with format when
> ordered correctly.
> How can the desired order be obtained in Proc Report with data that is in
> the correct group order to start?
>
> 2. How can the title flagindex column title be removed or changed
> to "revision" inside proc report. Renaming FlagIndex outside Proc report
> will do it but it's not preferable.
>
> 3. I would like to add a single blank line ant the end of each group. The
> proc report command used did more than this simple task.
>
> TIA,
> John
>
> Pleases send a CC to caraj@cox.net
>
|
|
0
|
|
|
|
Reply
|
datanull (3058)
|
8/15/2007 9:31:32 PM
|
|
|
1 Replies
33 Views
(page loaded in 0.12 seconds)
|