Date: Sat, 25 Sep 2004 14:46:12 +0000
Reply-To: iw1junk@COMCAST.NET
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ian Whitlock <iw1junk@COMCAST.NET>
Subject: Re: Retain not retain
Bob,
There are only three ways the value of VALID can get set to blank
1) explicit assignment
2) set to missing by the system at the beginning of a BY-group in reading multiple SAS data sets.
3) clobbered by input from SAS or external data
Your step rules out 1 and 2.
> data check;
> set test;
> by id measure;
>
> retain valid;
>
> if first.id then valid=.;
>
> if measure=2 then valid=1;
> run;
VALID must be a variable in TEST. The fact that the print shows blank
leads me to think VALID is defined as character in TEST unless
the option MISSING is set to blank. Since I cannot verify what
you have, but you can, I suggest that you take a look at TEST.
If VALID is not there, then make the data set TEST from cards
and show your log.
Ian_Whitlock@comcast.net
=================================
Date: Fri, 24 Sep 2004 16:36:40 -0700
Reply-To: Bob Lan <baoxian_lan@EXCITE.COM>
Sender: "SAS(r) Discussion"
From: Bob Lan <baoxian_lan@EXCITE.COM>
Organization: http://groups.google.com
Subject: Retain not retain
Content-Type: text/plain; charset=ISO-8859-1
Dear all,
Can anyone tell me what happened here?
Here is the code:
proc sort data=test;
by id measure;
run;
data check;
set test;
by id measure;
retain valid;
if first.id then valid=.;
if measure=2 then valid=1;
run;
title;
proc print data=check;
var id measure valid;
run;
Here is the result I have never seen before and don't know what happened:
Obs id measure valid
1 100000 2 1
2 100000 4 1
3 100000 5 1
4 100100 2 1
5 100100 4 1
6 100100 5 1
7 100800 2 1
8 100800 4
9 100800 5
10 102100 2 1
11 102100 4 1
12 102100 5 1
13 102400 2 1
14 102400 4
15 102900 2 1
16 102900 4
17 102900 5
|