From: SAS_learner on
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