Date: Tue, 13 May 2008 00:51:25 -0400
Reply-To: Tom Smith <need_sas_help@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Tom Smith <need_sas_help@YAHOO.COM>
Subject: Re: A Dataset Modification help Needed to create another dataset
On Mon, 12 May 2008 21:15:07 -0400, Muthia Kachirayan
<muthia.kachirayan@GMAIL.COM> wrote:
>On Mon, May 12, 2008 at 3:10 PM, Tom Smith <need_sas_help@yahoo.com>
wrote:
>
>> I have a following dataset having variables:SUB, HR, PQ, HJ as bellow:
>>
>> SUB HR PQ HJ
>> 1003 post Hadsone Cause
>> 1003 pre Green bay Location
>> 1004 post Jamsed Reason
>> 1004 post Winona City
>> 1004 Pre PullMan ZIp
>>
>> Need to create another dataset which will be by the variable SUB as
below
>> (means
>> it will have only one observation for each SUB variable's value ( Not a
>> proc report):
>>
>>
>>
>>
>>
>> SUB HR PQ HJ
>> 1003 post Hadsone Cause
>> pre Green bay Location
>> 1004 post Jamsed Reason
>> post Winona City
>> Pre PullMan ZIp
>>
>>
>> Can you help me ? I think by Proc tabulate we can do it. But
>> I forget the statement to use to create a dataset from Proc tabulate.
>> Please help me out even if you have any better approach other than
>> tabulate.
>> Thanks a lot for helping.
>>
>
>Tom,
>
>Howard gave a solution giving 5 records of output for the sample data set.
>If you have meant it to be one record per SUB, then here is an array
>approach. This solution assumes that there is no more than 3 rows per SUB
as
>a requirement for dimensioning the v[ ] array. You can add additional
>elements(3) to v[ ] per each row.
>
>data need;
>do _n_ = 1 by 1 until(last.sub);
> set have;
> by sub;
> length v1 $8 v2 $9 v3 $8 v4 $8 v5 $9 v6 $8 v7 $8 v8 $9 v9 $8;
> array s HR PQ HJ;
> array v[9] v1-v9;
> do over s;
> v[(_n_ - 1) * 3 + _i_] = s;
> end;
>end;
>drop hr pq hj;
>run;
>
>proc print data = need;
>run;
>
>Muthia Kachirayan
I had posted this problem earlier. But guesss I could not make it clear in
my last post. So I think I cofused those who tried to help me out. So I am
trying to make it clear below and more simple:
I have a following dataset having variables:SUB, HR as bellow:
SUB HR
1003 post
1003 pre
1004 post
1004 post
1004 Pre
1005 post
1005 pre
1005 failed
1005 never tried
Need to create another dataset from it which will be by the variable SUB
as below(means it will have only one observation for each SUB variable's
value and all the values for HR for that perticular value of SUB will be
in the same record one after another. Plz do not use Proc Report. I need a
dataset.
SUB HR
1003 post /
pre
1004 post /post /
Pre
1005 post / pre /
failed /
never tried
|