The SAS Output Delivery System and reporting techniques

Restrict a data set to a specific factor/label

Reply
N/A
Posts: 0

Restrict a data set to a specific factor/label

Hello,

I'm working with large datasets. With only a part of the dataset I want to do calculations. How can I filter or restrict my data set in such a manner that only the important data is included. I have columns with labels on which I can select.

e.g. a dataset:
Names dataA dataB
NameA 1 2
NameB 1 3
NameC 1 4
NameB 3 6
NameC 5 9
NameB 5 9
NameA 3 0
NameB 7 0

I want only the observations with the label NameB, thus the result must be the dataset:

Names dataA dataB
NameB 1 3
NameB 3 6
NameB 5 9
NameB 7 0

I tried some things with proc sort, but then the dataset is sorted according to the labels, but I want to exclude the data which have not the right label.

Thanks in advance,

Govert
Frequent Contributor
Posts: 91

Re: Restrict a data set to a specific factor/label

try something like:
proc sort data=instuff out=outstuff;
by var1 var2 ...;
where names = 'NameB';
run;
N/A
Posts: 0

Re: Restrict a data set to a specific factor/label

I tried your suggestion yesterday night.

It works!

Thanks a lot!

govert
N/A
Posts: 0

Re: Restrict a data set to a specific factor/label

Try This..

proc sql noprint;
create table dataset1 as
select * from dataset
where Names eq "NameB";
quit;


Srinu
Ask a Question
Discussion stats
  • 3 replies
  • 129 views
  • 0 likes
  • 2 in conversation