Date: Thu, 21 Mar 2002 16:25:30 -0500
Reply-To: Howard_Schreier@ITA.DOC.GOV
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Howard_Schreier@ITA.DOC.GOV
Subject: Re: set list of 'mixed' variables to missing
Here's a method using just the DATA step, but no ARRAYs.
Start with the test data (I added a couple of observations to make things
more general):
data old;
input ID TEST VAR ANIMAL TEXT $ TAPE $;
cards;
1 1 7 3 dgffg hghg
2 7 4 2 hghf hhh
3 4 5 3 dgffg hghg
4 7 . . . hhh
5 6 5 3 dgffg hghg
6 1 2 3 a b
7 4 5 6 c d
;
I assume that the target observations are enumerated in a dataset, something
like this:
data missobs;
input id;
cards;
2
6
;
I assume that the target variables are identified in a macrovariable:
%let missvar = var animal text;
First, create a dataset containing only the target variables and no
observations:
data missvar;
set old(obs=0);
keep &MISSVAR;
run;
Now create a dataset containing all of the missing values to be inserted:
data missing;
merge missobs missvar;
run;
Now plug in:
data new;
merge old missing;
by id;
run;
The intermediate datasets could be created as views instead. This would save
I/O and disk space if the number of observations is significant.
On Thu, 21 Mar 2002 15:51:54 +0100, Annette <anne5432@UNI.DE> wrote:
>hello,
>However, I am to set to missing selected mixed (num, char) vars (e.g. VAR,
>ANIMAL, and
>TEXT) in selected rows (by ID). I guess some ARRAY would be convenient, but
>my efforts were not uccessful until now. The data set contains hundreds of
>character and numeric vars. The idea is this:
>old:
>ID TEST VAR ANIMAL TEXT TAPE
>1 1 7 3 dgffg hghg
>2 7 4 2 hghf hhh
>3 4 5 3 dgffg hghg
>4 7 . . . hhh
>5 6 5 3 dgffg hghg
>;
>new:
>ID TEST VAR ANIMAL TEXT TAPE
>1 1 7 3 dgffg hghg
>2 7 . . . hhh
>3 4 5 3 dgffg hghg
>4 7 . . . hhh
>5 6 5 3 dgffg hghg
>;
>Thank you in advance,
>Annette