From: Arthur Tabachneck on
There are probably many ways of solving your problem. For one, couldn't
you create a master local macro variable and only change it if the value
of the current one isn't missing?

Art
-------
On Mon, 8 Mar 2010 16:08:19 -0800, SAS_learner <proccontents(a)GMAIL.COM>
wrote:

>Hello all ,
>
>#### trying to retain the value of Macro from one dataset to another. If
the
>Value of Pagen is missing then use the previous macro value of Pagedn of
the
>previous dataset.
>
>
>I am not sure how to explain the condition I am having. What I am doing is
>generating a Patient Profiles Listing and in the I am trying to determine
>the page number for each Individual subject the way I am doing is that I
>
>I am getting the pagen variable something like this
>
>%let pagen=2;
>%let maxline=23;
>
>data mhdem;
> set mhdem;
> by usubjid subjid mhscat mhterm;
> retain pagen linen;
> if first.usubjid then do;
> pagen=&pagen;
> linen=0;
> end;
> if linen<&maxline then do;
> linen=linen+1;
> end;
> else do;
> linen=1;
> pagen+1;
> end;
>run;
>
>And storing the pagen value in a macro I am increasing pagen value to next
>domain in Report. My Problem comes when there is No observations for given
>subject in a domain say for example for Usubjid = 1004 there is no leasion
>values so the pagen value for that would be 0 or missing instead of retain
>the previous value of pagedn. This is affecting the pagedn value of next
>dataset where I am trying to get the value of previous pagedn,
>
>
>
>MPRINT(SUBPROF): proc sql noprint;
>MPRINT(SUBPROF): select max(pagen)+1 into: pagen from mhdem;
>MPRINT(SUBPROF): quit;
>==== Next Page start from 4
>
>After that I am checking for LESION EVALUATION
>
>MPRINT(SUBPROF): proc sort data=lsdem;
>MPRINT(SUBPROF): by usubjid subjid pagen visitnum lsseq;
>MPRINT(SUBPROF): run;
>
>NOTE: Input data set is empty.
>NOTE: The data set WORK.LSDEM has 0 observations and 40 variables.
>
>MPRINT(SUBPROF): proc sql noprint;
>MPRINT(SUBPROF): select max(pagen)+1 into: pagen from lsdem;
>MPRINT(SUBPROF): quit;
>
>
>What I have What I want is
>Page 1 -------------> Demog and Dosing Information
>-----------------Pagedn value is 1
>Page 2 ------------------------>>>MH information
>-----------------Pagedn value is 4
>-----------------Pagedn value is 4
>Page 3 --------------------------->>LESION EVALUATION
>-----------------Pagedn value is missing -----------------
Pagedn
>value is missing
>Page 4 ----------------------->> Drug Information
>-----------------Pagedn value is 1
>-----------------Pagedn value is 4
>
>P.S if you feel that I am clear enough please let me know I would get back
>with an example but it would little lengthy
>
>Thanks for your help
>SL
From: SAS_learner on
Is there an example of something to display how that can do.

thanks
Kumar

On Mon, Mar 8, 2010 at 5:01 PM, Arthur Tabachneck <art297(a)netscape.net>wrote:

> There are probably many ways of solving your problem. For one, couldn't
> you create a master local macro variable and only change it if the value
> of the current one isn't missing?
>
> Art
> -------
> On Mon, 8 Mar 2010 16:08:19 -0800, SAS_learner <proccontents(a)GMAIL.COM>
> wrote:
>
> >Hello al
> >
> >#### trying to retain the value of Macro from one dataset to another. If
> the
> >Value of Pagen is missing then use the previous macro value of Pagedn of
> the
> >previous dataset.
> >
> >
> >I am not sure how to explain the condition I am having. What I am doing is
> >generating a Patient Profiles Listing and in the I am trying to determine
> >the page number for each Individual subject the way I am doing is that I
> >
> >I am getting the pagen variable something like this
> >
> >%let pagen=2;
> >%let maxline=23;
> >
> >data mhdem;
> > set mhdem;
> > by usubjid subjid mhscat mhterm;
> > retain pagen linen;
> > if first.usubjid then do;
> > pagen=&pagen;
> > linen=0;
> > end;
> > if linen<&maxline then do;
> > linen=linen+1;
> > end;
> > else do;
> > linen=1;
> > pagen+1;
> > end;
> >run;
> >
> >And storing the pagen value in a macro I am increasing pagen value to next
> >domain in Report. My Problem comes when there is No observations for given
> >subject in a domain say for example for Usubjid = 1004 there is no leasion
> >values so the pagen value for that would be 0 or missing instead of retain
> >the previous value of pagedn. This is affecting the pagedn value of next
> >dataset where I am trying to get the value of previous pagedn,
> >
> >
> >
> >MPRINT(SUBPROF): proc sql noprint;
> >MPRINT(SUBPROF): select max(pagen)+1 into: pagen from mhdem;
> >MPRINT(SUBPROF): quit;
> >==== Next Page start from 4
> >
> >After that I am checking for LESION EVALUATION
> >
> >MPRINT(SUBPROF): proc sort data=lsdem;
> >MPRINT(SUBPROF): by usubjid subjid pagen visitnum lsseq;
> >MPRINT(SUBPROF): run;
> >
> >NOTE: Input data set is empty.
> >NOTE: The data set WORK.LSDEM has 0 observations and 40 variables.
> >
> >MPRINT(SUBPROF): proc sql noprint;
> >MPRINT(SUBPROF): select max(pagen)+1 into: pagen from lsdem;
> >MPRINT(SUBPROF): quit;
> >
> >
> >What I have What I want is
> >Page 1 -------------> Demog and Dosing Information
> >-----------------Pagedn value is 1
> >Page 2 ------------------------>>>MH information
> >-----------------Pagedn value is 4
> >-----------------Pagedn value is 4
> >Page 3 --------------------------->>LESION EVALUATION
> >-----------------Pagedn value is missing -----------------
> Pagedn
> >value is missing
> >Page 4 ----------------------->> Drug Information
> >-----------------Pagedn value is 1
> >-----------------Pagedn value is 4
> >
> >P.S if you feel that I am clear enough please let me know I would get back
> >with an example but it would little lengthy
> >
> >Thanks for your help
> >SL
>
From: Arthur Tabachneck on
Kumar,

I was thinking of something simple like:

%global master;
%macro testit (test);
data _null_;
%if %length(&test) gt 0 %then %do;
%let master=&test;
%end;
%put master=&master;
run;
%mend testit;
%testit(3)
%testit()
%testit(5)

Art
---------
On Mon, 8 Mar 2010 20:26:30 -0800, SAS_learner <proccontents(a)GMAIL.COM>
wrote:

>Is there an example of something to display how that can do.
>
>thanks
>Kumar
>
>On Mon, Mar 8, 2010 at 5:01 PM, Arthur Tabachneck
<art297(a)netscape.net>wrote:
>
>> There are probably many ways of solving your problem. For one, couldn't
>> you create a master local macro variable and only change it if the value
>> of the current one isn't missing?
>>
>> Art
>> -------
>> On Mon, 8 Mar 2010 16:08:19 -0800, SAS_learner <proccontents(a)GMAIL.COM>
>> wrote:
>>
>> >Hello al
>> >
>> >#### trying to retain the value of Macro from one dataset to another.
If
>> the
>> >Value of Pagen is missing then use the previous macro value of Pagedn
of
>> the
>> >previous dataset.
>> >
>> >
>> >I am not sure how to explain the condition I am having. What I am
doing is
>> >generating a Patient Profiles Listing and in the I am trying to
determine
>> >the page number for each Individual subject the way I am doing is that
I
>> >
>> >I am getting the pagen variable something like this
>> >
>> >%let pagen=2;
>> >%let maxline=23;
>> >
>> >data mhdem;
>> > set mhdem;
>> > by usubjid subjid mhscat mhterm;
>> > retain pagen linen;
>> > if first.usubjid then do;
>> > pagen=&pagen;
>> > linen=0;
>> > end;
>> > if linen<&maxline then do;
>> > linen=linen+1;
>> > end;
>> > else do;
>> > linen=1;
>> > pagen+1;
>> > end;
>> >run;
>> >
>> >And storing the pagen value in a macro I am increasing pagen value to
next
>> >domain in Report. My Problem comes when there is No observations for
given
>> >subject in a domain say for example for Usubjid = 1004 there is no
leasion
>> >values so the pagen value for that would be 0 or missing instead of
retain
>> >the previous value of pagedn. This is affecting the pagedn value of
next
>> >dataset where I am trying to get the value of previous pagedn,
>> >
>> >
>> >
>> >MPRINT(SUBPROF): proc sql noprint;
>> >MPRINT(SUBPROF): select max(pagen)+1 into: pagen from mhdem;
>> >MPRINT(SUBPROF): quit;
>> >==== Next Page start from 4
>> >
>> >After that I am checking for LESION EVALUATION
>> >
>> >MPRINT(SUBPROF): proc sort data=lsdem;
>> >MPRINT(SUBPROF): by usubjid subjid pagen visitnum lsseq;
>> >MPRINT(SUBPROF): run;
>> >
>> >NOTE: Input data set is empty.
>> >NOTE: The data set WORK.LSDEM has 0 observations and 40 variables.
>> >
>> >MPRINT(SUBPROF): proc sql noprint;
>> >MPRINT(SUBPROF): select max(pagen)+1 into: pagen from lsdem;
>> >MPRINT(SUBPROF): quit;
>> >
>> >
>> >What I have What I want is
>> >Page 1 -------------> Demog and Dosing Information
>> >-----------------Pagedn value is 1
>> >Page 2 ------------------------>>>MH information
>> >-----------------Pagedn value is 4
>> >-----------------Pagedn value is 4
>> >Page 3 --------------------------->>LESION EVALUATION
>> >-----------------Pagedn value is missing -----------------
>> Pagedn
>> >value is missing
>> >Page 4 ----------------------->> Drug Information
>> >-----------------Pagedn value is 1
>> >-----------------Pagedn value is 4
>> >
>> >P.S if you feel that I am clear enough please let me know I would get
back
>> >with an example but it would little lengthy
>> >
>> >Thanks for your help
>> >SL
>>
From: Toby Dunn on
Ever thought about using a By or Class statement (depending on the
procedure used for printing) and then use linesize and/or Pagesize options
to control the max columns and rows to print on a page. Just a thought.

Toby Dunn


On Mon, 8 Mar 2010 16:08:19 -0800, SAS_learner <proccontents(a)GMAIL.COM>
wrote:

>Hello all ,
>
>#### trying to retain the value of Macro from one dataset to another. If
the
>Value of Pagen is missing then use the previous macro value of Pagedn of
the
>previous dataset.
>
>
>I am not sure how to explain the condition I am having. What I am doing is
>generating a Patient Profiles Listing and in the I am trying to determine
>the page number for each Individual subject the way I am doing is that I
>
>I am getting the pagen variable something like this
>
>%let pagen=2;
>%let maxline=23;
>
>data mhdem;
> set mhdem;
> by usubjid subjid mhscat mhterm;
> retain pagen linen;
> if first.usubjid then do;
> pagen=&pagen;
> linen=0;
> end;
> if linen<&maxline then do;
> linen=linen+1;
> end;
> else do;
> linen=1;
> pagen+1;
> end;
>run;
>
>And storing the pagen value in a macro I am increasing pagen value to next
>domain in Report. My Problem comes when there is No observations for given
>subject in a domain say for example for Usubjid = 1004 there is no leasion
>values so the pagen value for that would be 0 or missing instead of retain
>the previous value of pagedn. This is affecting the pagedn value of next
>dataset where I am trying to get the value of previous pagedn,
>
>
>
>MPRINT(SUBPROF): proc sql noprint;
>MPRINT(SUBPROF): select max(pagen)+1 into: pagen from mhdem;
>MPRINT(SUBPROF): quit;
>==== Next Page start from 4
>
>After that I am checking for LESION EVALUATION
>
>MPRINT(SUBPROF): proc sort data=lsdem;
>MPRINT(SUBPROF): by usubjid subjid pagen visitnum lsseq;
>MPRINT(SUBPROF): run;
>
>NOTE: Input data set is empty.
>NOTE: The data set WORK.LSDEM has 0 observations and 40 variables.
>
>MPRINT(SUBPROF): proc sql noprint;
>MPRINT(SUBPROF): select max(pagen)+1 into: pagen from lsdem;
>MPRINT(SUBPROF): quit;
>
>
>What I have What I want is
>Page 1 -------------> Demog and Dosing Information
>-----------------Pagedn value is 1
>Page 2 ------------------------>>>MH information
>-----------------Pagedn value is 4
>-----------------Pagedn value is 4
>Page 3 --------------------------->>LESION EVALUATION
>-----------------Pagedn value is missing -----------------
Pagedn
>value is missing
>Page 4 ----------------------->> Drug Information
>-----------------Pagedn value is 1
>-----------------Pagedn value is 4
>
>P.S if you feel that I am clear enough please let me know I would get back
>with an example but it would little lengthy
>
>Thanks for your help
>SL