Date: Tue, 6 Sep 2005 11:42:00 -0400
Reply-To: Jim Groeneveld <jim1stat@YAHOO.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jim Groeneveld <jim1stat@YAHOO.CO.UK>
Subject: Re: Explanation of missing values
Hi Bernie,
I've been carefully examining your code, but I could not find any
explanation for missing silhydro values. However, you say you presented the
entire data step. But as it is, is very likely does not run, because of the
erroneous line:
> lensmat ne '' and label1 ne '' and spflag=0)); */
It is an incomplete statement and ends with an end-of-comment mark.
Anyway, without the input datasets it is not possible to solve this problem
from a distance. I would advice you to add the statement:
IF Silhydro LE .z THEN PUT new_ID= Silhydro=;
just before the RUN; statement. Instead of new_ID any record-identifying
variable could be taken.
Then restrict the input data to the (a few) records that cause the missing
values. Subsequently remove advancing code until you see the value of
Silhydro getting non-missing. This way try to discover what is happening.
Good luck - Jim.
P.S. Improve the layout for readibility, consequent indenting.
On Tue, 6 Sep 2005 10:47:51 -0400, Bernie Zimmerman <beezee@EROLS.COM>
wrote:
>Dear SAS-L:
>
>Several of you have replied to my message and I would like to thank all of
>you, collectively. In particular, Jim Groeneveld asked to see several
lines
>before (and after?) the code I posted. In an effort to give you a flavor
of
>what we have, here is the entire data step to the best of my copy and paste
>ability ..
>
> data month ;
> length new_ID $14 ; /* combines 'label1' & 'monyyx' */
>
> set xtra_1(in= mo1)
> xtra_2(in= mo2)
> xtra_3(in= mo3) ;
>
>
> where "&window1"d le date le "&window2"d;
> lensmat ne '' and label1 ne '' and spflag=0)); */
>
> %if %upcase(&month_quarter) = QUARTER %then %do;
> retain panel "&panel";
> %end;
> %else %do;
> retain panel "01&panel"d ;
> format panel date9.;
> %end;
>
> length new_brand_2 $ 50
> region $ 7 ;
>
> %if %upcase(&month_quarter) = QUARTER %then %do;
> year = 2000 + input(substr("&panel", 3, 2), 2.);
> qtr = input(substr("&panel", 1, 1), 1.);
> %end;
> %else %do;
> year = year(panel);
> qtr = qtr(panel);
> %end;
>
> /* attributes the same, all months */
> if vtype(rgcd)= 'N' then do ;
> region = put(rgcd, reg.) ;
> end ;
>
> else if vtype(rgcd)= 'C' then do ;
> region = put(rgcd, $reg.);
> end ;
>
>
> *recode brands that were bought by other companies *;
> if brand ne . then do;
> if substr(trim(left(put(brand, best8.))), 1, 2) = '49'
> then new_brand = input(put(brand, br49fmt.), best8.);
> else new_brand = input(put(brand, brndfmt.), 8.);
> end;
> new_brand_2 = put(new_brand, brnfmt.);
>
> manufacturer = put(manuf, manfmt.);
>
>* code taken from the program used to create the In-Sight data, but applied
>after the dataset is created and before the flat file is created -- this
>defines the "modality as marketed" ;
>if brand in (2452,2534,2578,2583,3007,3675,3677,2662) then mod3 = 1 ;
>/*1-day */
>else if modality = 1 then mod3 = 2 ; /*other*/
>ELSE if modality = 2 and brand in
>
(2454,2527,2528,2529,2579,2630,2633,2634,2637,2638,2640,2647,2657,2658,2648,
2649,2650,2651,2653,2655,2683,
>3621,3622,3802,4201,4203,4204,4205,4996,4997,4301,4302,49141,49150)
> then mod3 = 3 ; /* monthly */
>else if modality = 2 then mod3 = 4 ; /* quarterly */
>else if modality = 3 then mod3 = 5 ; /* conventional */
>
> /* create "silhydro" var. for older months, 8/10/2005 */
> if brand in (2454, 2579, 2586, 3014, 3015, 3016) then silhydro= 1 ;
> else silhydro= 00 ;
>
>/*power lenses -- modality as marketed = Other and Monthly
> lens tinting = no tinit and handling spherical */
>if mod3 in (2, 3)
>and tinting in (0, 1)
>and torbifo = 0
>then powerlens = 1;
>else powerlens = 0;
>
> **length new_ID $14 ; /* combines 'label1' & 'monyyx' */
>
> if mo1 then do ;
> new_ID= label1 || '-1' || upcase("&MONYY1.") ; /* should work ??
*/
> end ;
> else if mo2 then do ;
> new_ID= label1 || '-2' || upcase("&MONYY2.") ;
> end ;
> else if mo3 then do ;
> new_ID= label1 || '-3' || upcase("&MONYY3.") ;
> end ;
>
> /* per discussion w. Linda, 8/8/2005 */
> if new_intro= 1 then do ;
> new_intro = 0 ;
> new_intro1= 'No' ;
> end ;
>
> /* drop these *old* projected lens variables on the way in .. 8/09/2005
*/
> DROP PJNSCL PJNSCLR PJNSCLTR PJNSCLRV PJTRIAL PJREVLNS PJPACKS
>PJRFSCL PJRPSCL
> PJTOTSCL PJNCCL PJNCCLR PJRFCCL PJRPCCL PJTOTCCL PJRPSPAT
>PJRPCPAT PJRPHPAT
> PJNHCL PJNHCLR PJRFHCL PJRPHCL PJTOTHCL ;
> /* drop projected kit variables as well .. */
> DROP PJTHERM PJCHNOPE PJPEROX PJRGPKIT ;
>run;
>
>
>Also, as an FYI, I am running this job with the "month_quarter" macro
>variable set to *month*. I did not (yet) try Joep's suggestion of
beginning
>my 'if .. then .. else ..' section initialising the variable to zero.
Can't
>see why that could explain what I'm noticing.
>
>Thanks again in advance.
>
>Bernie Zimmerman
|