| Date: | Fri, 19 Jan 2007 00:09:47 -0500 |
| Reply-To: | Amy Sun <tonyliang20032@GMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Amy Sun <tonyliang20032@GMAIL.COM> |
| Subject: | Re: generating page numbers |
|
| In-Reply-To: | <BAY123-F5F5BBCFF62C6B7992E9E8DEA90@phx.gbl> |
| Content-Type: | text/plain; charset=ISO-8859-1; format=flowed |
Thank you, Toby.
I will use that dataset for PROC REPORT, and my idea is that I set the
maximum observation numbers for each page, and in my code, I set it as 30. I
believe that kind of data structure is necessary for my special purpose, and
after running that macro, my report will have a page break in each treatment
if the observation number satisfies the condition
if 30*(i-1) < obs <= 30 * i then page = i;
meanwhile, if we have a new treatment group, then we will also have another
page break, i.e. starting a new page
Best regards,
Amy
On 1/19/07, toby dunn <tobydunn@hotmail.com> wrote:
>
> Amy ,
>
> I am still not sure what your desired output should even look like. Where
> should the breaks be at your exmaple below doesnt give me any rules ad it
> doesnt match one page per Treatment Group.
>
> But If I was to take a stab at it I would use By Group Processing.
>
> Data Have ;
> Do TRT = 1 To 3 ;
> Do Cnt = 1 To 40 ;
> Output ;
> End ;
> End ;
> Run ;
>
>
> Options Nonumber NoByLine NoDate ;
>
> Title "For #ByVal1" ;
>
> Proc Print
> Data = Have NoObs;
> By Trt ;
> Var Trt Cnt ;
> Run ;
>
>
>
>
> Toby Dunn
>
> To sensible men, every day is a day of reckoning. ~John W. Gardner
>
> The important thing is this: To be able at any moment to sacrifice that
> which we are for what we could become. ~Charles DuBois
>
> Don't get your knickers in a knot. Nothing is solved and it just makes you
> walk funny. ~Kathryn Carpenter
>
>
>
>
>
>
> From: Amy Sun <tonyliang20032@GMAIL.COM>
> Reply-To: Amy Sun <tonyliang20032@GMAIL.COM>
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: generating page numbers
> Date: Thu, 18 Jan 2007 23:46:55 -0500
>
> I want the page break for each treatment, if there is an easier way to do
> that, it will be great, I am not sure if I can share the code with you.
>
> Thank you for your help.
>
> Amy
>
> On 1/18/07, toby dunn <tobydunn@hotmail.com> wrote:
> >
> >Amy ,
> >
> >This may sound weird but why woudl you want to go through all this
> trouble
> >when there a multitude of easier ways to get page numbers now a days in
> >SAS.
> > Alot will depend on what format you want to print the data out
> too. So
> >if
> >we knew that and what rules you want to put what observations to what
> page
> >we could offer better advice.
> >
> >
> >
> >Toby Dunn
> >
> >To sensible men, every day is a day of reckoning. ~John W. Gardner
> >
> >The important thing is this: To be able at any moment to sacrifice that
> >which we are for what we could become. ~Charles DuBois
> >
> >Don't get your knickers in a knot. Nothing is solved and it just makes
> you
> >walk funny. ~Kathryn Carpenter
> >
> >
> >
> >
> >
> >
> >From: Amy Sun <tonyliang20032@GMAIL.COM>
> >Reply-To: Amy Sun <tonyliang20032@GMAIL.COM>
> >To: SAS-L@LISTSERV.UGA.EDU
> >Subject: generating page numbers
> >Date: Thu, 18 Jan 2007 23:36:15 -0500
> >
> >Hi, all;
> >
> >I want to generate the page number for a dataset, there are several
> >treatment groups: 1, 2, 3. I want the final dataset will have the page
> >number information for each treatment, the following is my expectation:
> >
> >trt obs newobs page
> >1 1 1 1
> >........
> >1 30 30 1
> >1 31 31 2
> >.....
> >1 40 40 2
> >
> >2 1 41 3
> >........
> >2 30 70 3
> >2 31 71 4
> >.....
> >2 40 80 4
> >
> >3 1 81 5
> >........
> >3 30 110 5
> >3 31 111 6
> >.....
> >3 40 120 6
> >
> >I want to write a macro to present the above dataset, while something
> >should
> >be wrong with my following code
> >
> >data page (drop = obs);
> >do trt = 1 to 3;
> > do obs = 1 to 40;
> > output;
> > end;
> >end;
> >run;
> >
> >%macro pager(dsin =, var =);
> >%global num0 maxobs num1;
> >
> >proc sort data = &dsin;
> >by &var;
> >
> >data pp;
> >set &dsin;
> >by &var;
> >if first.&var then obs = 0;
> >obs + 1;
> >newobs + 1;
> >
> >proc sql;
> >create table er as
> > select *, ceil(max(obs)/30) as pagen
> > from pp
> > group by &var;
> >quit;
> >
> >proc sort data = er;
> >by &var obs;
> >
> >proc sql noprint;
> > select pagen into : num0
> > from er
> > where obs = newobs;
> > select max(newobs) into : maxobs
> > from er
> > where obs = newobs;
> >quit;
> >
> >data total;
> >set er;
> >by &var;
> >if first.&var then output;
> >
> >proc sql noprint;
> > select sum(pagen) into : totalpage
> > from total;
> >quit;
> >
> >data er (drop = i);
> >set er end = eof;
> >if obs = newobs then do;
> > do i = 1 to &num0;
> > if 30 * (i-1) < obs <= 30*i then page = i;
> > end;
> >end;
> >if eof then stop;
> >
> >%do;
> >proc sql noprint;
> > select pagen into : pagea
> > from er
> > where page ne . ;
> >quit;
> >
> >%do j = 1 %to &pagea;
> >proc sql noprint;
> >select max(newobs) into : num1
> > from er
> > where page ne . ;
> >
> >data er;
> >set er;
> >if newobs - obs = &num1 then do;
> > if 30 * %eval(&j-1) < obs <= 30*%eval(&j) then page =
> %eval(&num0
> >+
> >&j);
> >end;
> >%end;
> >
> >%end;
> >
> >proc sql noprint;
> > select pagen into : num0
> > from er
> > where page ne . ;
> > select max(newobs) into : maxobs
> > from er
> > where page ne . ;
> >quit;
> >
> >%mend;
> >%pager(dsin = page, var = trt);
> >proc print data = er;
> >run;
> >
> >please take a look at my code. Thanks in advance for your suggestions.
> >
> >Best regards,
> >Amy
> >
> >_________________________________________________________________
> >Search for grocery stores. Find gratitude. Turn a simple search into
> >something more.
> >
> >
> http://click4thecause.live.com/search/charity/default.aspx?source=hmemtagline_gratitude&FORM=WLMTAG
> >
> >
>
> _________________________________________________________________
> Type your favorite song. Get a customized station. Try MSN Radio powered
> by Pandora. http://radio.msn.com/?icid=T002MSN03A07001
>
>
|