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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 460 views
  • 0 likes
  • 3 in conversation