BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
3 REPLIES 3
advoss
Quartz | Level 8
try something like:
proc sort data=instuff out=outstuff;
by var1 var2 ...;
where names = 'NameB';
run;
deleted_user
Not applicable
I tried your suggestion yesterday night.

It works!

Thanks a lot!

govert
deleted_user
Not applicable
Try This..

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


Srinu

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 769 views
  • 0 likes
  • 2 in conversation