BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
robertrao
Quartz | Level 8


Hi,

I have a dataset........."HAVE"

I want a variable in it lets say Category: and has values A, B, C, D, E, F, G.there are numerous

I want to split my HAVE data into 2: one containing "all the category values" and the other containing say for example E

data want_all want_E

set have;

if category eq E then output want_E

;

run;

is the above logic right????

since I dint write any logic for want_all does all the records go into it automatically?????

Again , do you have any better way to do it??/

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Just add an output statement. e.g.:

data want_all want_E;

set have;

output want_all;;

if category eq 'E' then output want_E;

run;

If there is a better way, I'm not aware of it.

View solution in original post

5 REPLIES 5
Reeza
Super User

Why don't you just test this rather than ask the question? Doesn't asking the question actually take longer?

Other than" is there a better way" you can probably test this to get your answer or read the documentation. 

robertrao
Quartz | Level 8

Hi Reeza,

I tested it before asking a question on the Community!!!

I am getting 0 records in the want_all...So I wanted to know how to get all the records into want_all.

Please don't mind.......I know asking the question takes longer but when you are stuck I think there is no other go to ask the experts ????

Thanks

art297
Opal | Level 21

Just add an output statement. e.g.:

data want_all want_E;

set have;

output want_all;;

if category eq 'E' then output want_E;

run;

If there is a better way, I'm not aware of it.

robertrao
Quartz | Level 8

You are all of great help .

Learning SAS is a continuous process ............atleast for me

Thanks

art297
Opal | Level 21

I've been continually trying to learn it for the past 40+ years.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1201 views
  • 0 likes
  • 3 in conversation