DATA STEP

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,040
Accepted Solution

DATA STEP


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


Accepted Solutions
Solution
‎10-31-2014 04:55 PM
Esteemed Advisor
Posts: 7,294

Re: DATA STEP

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


All Replies
Grand Advisor
Posts: 17,361

Re: DATA STEP

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. 

Super Contributor
Posts: 1,040

Re: DATA STEP

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

Solution
‎10-31-2014 04:55 PM
Esteemed Advisor
Posts: 7,294

Re: DATA STEP

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.

Super Contributor
Posts: 1,040

Re: DATA STEP

You are all of great help .

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

Thanks

Esteemed Advisor
Posts: 7,294

Re: DATA STEP

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

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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