From: laika on
Hi,

In the code below i have a problem with line "if dat EQ &datum then "
because this instruction doesn't work. I have missing values for v1
and v2.
I don't see what's wrong here.

Tx


options COMPRESS = YES ;
options OBS = MAX ;
options MPRINT NOCENTER ;

data _null_ ;
%let datum2 = 01nov2009 ;
%let datum = %sysfunc(inputN(&datum2,date9),yymmN6) ;
run ;

filename nnm 'c:\inp.txt' ;

data data.inp ;
infile inp obs = 1000 ;
input @25 dat 6. @ ;
if dat EQ &datum then
input
@1 v1 $8.
@9 v2 $16. ;
run ;
From: Patrick on
Also you only read the values for "v1" and "v2" in case of "dat EQ
&datum" you still write all lines to the output. Whenever the
condition "dat EQ &datum" is FALSE "v1" and "v2" will be missing.
Have a look at the following:


%let datum = 01nov2009 ;
%let datum = %sysfunc(inputN(&datum,date9),yymmN6) ;
%put datum= &datum;

data work.inp ;
/* infile inp obs = 1000 ; */
infile datalines;
input @25 dat 6. @ ;
if dat EQ &datum then
do;
input
@1 v1 $8.
@9 v2 $16. ;
output;
end;
datalines;
1aaaaaaabbbbbbbbbbbbbbbb200911
2aaaaaaabbbbbbbbbbbbbbbb200912
3aaaaaaabbbbbbbbbbbbbbbb200911
run ;
proc print data=work.inp;
run;


From: data _null_; on
On Dec 23, 4:49 am, laika <michel.verhe...(a)axa.be> wrote:
> Hi,
>
> In the code below i have a problem with line "if dat EQ &datum then "
> because this instruction doesn't work. I have missing values for v1
> and v2.
> I don't see what's wrong here.
>
> Tx
>
> options COMPRESS = YES ;
> options OBS  = MAX ;
> options MPRINT NOCENTER ;
>
> data _null_ ;
>   %let datum2 = 01nov2009 ;
>   %let datum  = %sysfunc(inputN(&datum2,date9),yymmN6) ;
> run ;
>
> filename nnm 'c:\inp.txt' ;
>
> data data.inp ;
>         infile inp obs = 1000 ;
>         input @25   dat     6. @ ;
>         if dat EQ &datum then
>                 input
>                 @1      v1      $8.
>                 @9      v2      $16. ;
> run ;

The INFILE statement does not read the file specified in the FILENAME
statement.

Also I would not use DAT and &DATUM as numeric values, but read DAT
with INFORMAT YYMMN6 and use DATNUM2 as date literal so you are
working with SAS dates.

%let datum2 = 01nov2009 ;
/*%let datum = %sysfunc(inputN(&datum2,date9),yymmN6) ; */
options parmcards=nnm;
filename nnm 'inp.txt' ;

data inp ;
infile nnm obs = 1000 ;
input @25 dat yymmn6. @ ;
if dat EQ "&datum2"d then do;
input
@1 v1 $8.
@9 v2 $16. ;
output;
end;
format dat yymmn6.;
parmcards;
abcdefgh1234567890123456200911
abcdefgh1234567890123456200911
abcdefgh1234567890123456200911
abcdefgh1234567890123456200910
abcdefgh1234567890123456200901
abcdefgh1234567890123456200901
;;;;
run;
proc print;
run;
From: Murphy Choy on
Hi,

You can try the missing function.


------Original Message------
From: William Shakespeare
Sender: SAS(r) Discussion
To: SAS-L(a)LISTSERV.UGA.EDU
ReplyTo: William Shakespeare
Subject: missing values
Sent: Jan 12, 2010 10:29 AM

I have a data set with millions of records. I want to pick out the first
1000 records with VAR1 ne missing. My file is sorted on VAR1 but I don't
know how many missing values there are (so I can't use >=_n_=x and <=
_n_=1000+x). How else could I get to this?


Sent from my BlackBerry Wireless Handheld

--
Regards,
Murphy Choy

Certified Advanced Programmer for SAS V9
Certified Basic Programmer for SAS V9
From: William Shakespeare on
Familiar with the function. Not sure how to apply it in this case. I
only want the first 1000 records that are not missing(VAR1). How do I
limit to 1000?