View Full Version : SAS data step doubt


karthikeya_ivb
04-15-2009, 05:04 AM
hi all,
here is the issue i'm working on:

i have a dataset with 'n' variables, of them 'm' have missing values at some observation. now i want to get an output dataset containing only n-m columns.
a small eg:
UPC STORE1 STORE2 STORE3 STORE4 STORE5

1 10 15 5 14 7
2 12 17 . 20 .
3 20 5 10 25 4
4 15 7 8 20 20
5 10 4 . 10 .

and the end result should be
UPC STORE1 STORE2 STORE4
1 10 15 14
2 12 17 20
3 20 5 25
4 15 7 20
5 10 4 10


please dont suggest to use proc transpose and do that. i'm looking for some other method.

I thank you,

-Karthik

vinux
04-15-2009, 06:02 AM
hi all,
here is the issue i'm working on:

i have a dataset with 'n' variables, of them 'm' have missing values at some observation. now i want to get an output dataset containing only n-m columns.
a small eg:
UPC STORE1 STORE2 STORE3 STORE4 STORE5

1 10 15 5 14 7
2 12 17 . 20 .
3 20 5 10 25 4
4 15 7 8 20 20
5 10 4 . 10 .

and the end result should be
UPC STORE1 STORE2 STORE4
1 10 15 14
2 12 17 20
3 20 5 25
4 15 7 20
5 10 4 10


please dont suggest to use proc transpose and do that. i'm looking for some other method.

I thank you,

-Karthik

why don't you use data step. Assuming that your first data set name is data1


data data2;
set data1( keep =UPC STORE1 STORE2 STORE4 );
run;

karthikeya_ivb
04-15-2009, 06:52 AM
yes, i can use the data step. but i dont know which variables have the missing values. dts the whole problem. i need to programatically recognise the missing values and then delete respective columns.

thanks a lot for your interest.

-Karthik

vinux
04-15-2009, 06:58 AM
PROC MEANS data = data1 NMISS;
var UPC STORE1 STORE2 STORE3 STORE4 STORE5;
run;

karthikeya_ivb
04-16-2009, 01:38 AM
thank you very much.
it worked using the nmiss option.

-Karthik