LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2004, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 20 Feb 2004 15:34:09 -0500
Reply-To:     diskin.dennis@KENDLE.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Dennis Diskin <diskin.dennis@KENDLE.COM>
Subject:      Re: Help needed with outputting..
Comments: To: Nagakumar Sridhar <nsridhar@ATHEROGENICS.COM>
Content-Type: text/plain; charset="us-ascii"


To automate something like this you pretty much have to go to a macro. The macro can retrieve the actual treatments into macro variable and then use them to build a datastep. For this to work, the treatment names must be valid as dataset names. E.g. not start with numbers or contain spaces or other invalid characters.

A sample macro: (I don't have time to test right now)

%macro split(data=); proc sql noprint; select distinct trim(trtmnt) into :ds1 thru :ds999 from &data where trtmnt ne ' '; %let n_ds = &sqlobs; quit;

data nulls %do i = 1 %to &n_ds; &&ds&i %end; ; set &data; select(trtmnt); %do i = 1 %to &n_ds; when("&&ds&i") output &&ds&i; %end; otherwise output nulls; end; run; %mend;


HTH, Dennis Diskin

Nagakumar Sridhar <nsridhar@ATHEROGENICS.COM> Sent by: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> 02/20/2004 03:21 PM Please respond to Nagakumar Sridhar

To: SAS-L@LISTSERV.UGA.EDU cc: Subject: Help needed with outputting..

Hi Folks:

Here's the (new!) question. I have a dataset like so:

Obs. Analyte trtmnt visit Status N

1453 WBC (THOUS/M) ds20mg DAY 5 I 1

1454 WBC (THOUS/M) ds20mg DAY 5 NC 4

1455 WBC (THOUS/M) ds320mg DAY 5 NC 5

1456 WBC (THOUS/M) ds40mg DAY 5 NC 6

1457 WBC (THOUS/M) ds5mg DAY 5 NC 6

1458 WBC (THOUS/M) ds640mg DAY 5 NC 6

1459 WBC (THOUS/M) ds80mg DAY 5 NC 6

1460 WBC (THOUS/M) dsplacebo DAY 5 NC 5

1461 WBC (THOUS/M) ds10mg DAY 6 NC 5

1462 WBC (THOUS/M) ds160mg DAY 6 NC 6

1463 WBC (THOUS/M) ds20mg DAY 6 D 1

1464 WBC (THOUS/M) ds20mg DAY 6 I 1

1465 WBC (THOUS/M) ds20mg DAY 6 NC 4

1466 WBC (THOUS/M) ds320mg DAY 6 NC 5

1467 WBC (THOUS/M) ds40mg DAY 6 NC 6

1468 WBC (THOUS/M) ds5mg DAY 6 NC 6

1469 WBC (THOUS/M) ds640mg DAY 6 NC 6

1470 WBC (THOUS/M) ds80mg DAY 6 NC 6

1471 WBC (THOUS/M) dsplacebo DAY 6 NC 5

1472 WBC (THOUS/M) ds10mg DAY 7 NC 5

1473 WBC (THOUS/M) ds160mg DAY 7 NC 6

1474 WBC (THOUS/M) ds20mg DAY 7 D 1

1475 WBC (THOUS/M) ds20mg DAY 7 I 2

1476 WBC (THOUS/M) ds20mg DAY 7 NC 3

1477 WBC (THOUS/M) ds320mg DAY 7 NC 5

1478 WBC (THOUS/M) ds40mg DAY 7 NC 6

1479 WBC (THOUS/M) ds5mg DAY 7 NC 6

1480 WBC (THOUS/M) ds640mg DAY 7 NC 6

1481 WBC (THOUS/M) ds80mg DAY 7 NC 6

1482 WBC (THOUS/M) dsplacebo DAY 7 I 1

1483 WBC (THOUS/M) dsplacebo DAY 7 NC 4

What I want to do is to output all the ds20mg to a dataset ds20mg and all ds40mg's to ds40mg and so on. If the treatment

Groups were defined (that is, if I knew how many treatment groups there were or what they were called) life would be easy. But that's not the case. The number is dynamic and so's the treatment groups.

Question is how would I be able to output the various observations to the different datasets, given the above conditions?

Thanks and regards


Back to: Top of message | Previous page | Main SAS-L page