| Date: | Fri, 30 Jan 2004 07:24:21 +1100 |
| Reply-To: | dg <queanbeyan@HOTMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | dg <queanbeyan@HOTMAIL.COM> |
| Subject: | Re: simple output depending on variable |
|---|
Thanks, I'll try all 3 responses (in SAS-L) at work today.
Cheers
Doug
"pudding man" <pudding_man@MAIL.COM> wrote in message
news:20040129164901.5339.qmail@mail.com...
> Doug is headed in the right direction. This is not
> difficult to do with array processing.
>
> If I had a moderate volume of data, I might structure
> something like (tested):
>
> data new(keep = id: item:);
> *set old;
> retain id 1 id2;
> array rels(144) relate_1 - relate_144;
> array item(12);
> do i = 1 to dim(rels); rels(i) = i; end; *** just for test ***;
>
> j = 1;
> do k = 1 to 144;
> item(j)=rels(k);
> j + 1;
> if mod(k, 12) = 0 then do; id2 + 1; output; j = 1; end;
> end;
> run;
>
> proc print; run;
>
> If I had tons of data, I might consider something
> with PEEK n' POKE:
>
> data new(keep = id: item:);
> *set old;
> retain id 1 id2;
> array rels(144) relate_1 - relate_144;
> array item(12);
> do i = 1 to dim(rels); rels(i) = i; end; *** just for test ***;
>
> do j = 1 to dim(rels) by 12;
> id2 + 1;
> call poke(peekc(addr(rels(j)), 8 * 12),addr(item(1)), 8 * 12);
> output;
> end;
> run;
>
> proc print; run;
>
> This latter should run a good bit faster ...
>
> Hope it hep' s...
>
> Prost,
> Puddin'
>
> *******************************************************
> *** Puddin' Man *** Pudding_Man@mail.com ********
> *******************************************************;
>
> Guantanamo, anyone?
>
> "The power of the executive to cast a man into prison
> without formulating any charge known to the law, and
> particularly to deny him the judgment of his peers, is in
> the highest degree odious, and the foundation of all
> totalitarian government whether Nazi or Communist."
> - Winston Churchill, 1943
>
> ----- Original Message -----
> From: dg <queanbeyan@HOTMAIL.COM>
> Date: Thu, 29 Jan 2004 22:00:33 +1100
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: simple output depending on variable
>
> I have a dataset that contains id, relate_1 to relate_144. Each value of
> relate_1 to relate_144 is numeric. Id = character.
>
> I would like to create a new dataset that has the following items;
> id, id2, item1 - item12.
>
> where
> id =id, id2=1, item1-item12 = relate_1 to relate_12 for the relate_1 to
> relate_12 variables,
> id=id, id2=2, item1-item12 = relate_13 to relate_24 for the next 12 relate
> variables etc down to .....
>
> id=id, id2=12, item1-item12=relate 131 to relate_144 for the last 12
relate
> variables
> and so on.
>
> This is what I have tried..
> data new;
> set old;
> array rels(144) relate_1 - relate_144;
> array item(12);
> do h=1 to 12;
> do i = h to 144 by 12;
> item(h)=rels(i);
> output;
> end;
> end;
> run;
>
> but this doesn't give me what I want. I suppose I want a vertical slice
> after each 12 relate variables and the number of the slice in a vertical
> file.
>
> Any help appreciated.
>
> Doug
>
>
>
> --
> _______________________________________________
> Get your free email from http://www.mail.com
|