| Date: | Thu, 7 Sep 2000 14:37:27 -0600 |
| Reply-To: | Amy Roehrig Swinford <aimless@FIBER.NET> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Amy Roehrig Swinford <aimless@FIBER.NET> |
| Organization: | Fibernet Inc. |
| Subject: | Re: transpose only four variables each time |
| Content-Type: | text/plain; charset=us-ascii |
Toni,
Given that you know the number of variables and questions, an easier way is
in the data step -
data xpose;
set x;
keep id q301-q314;
array ques(14) q301-q314;
array arr(14, 4) q301a--q314d;
do level=1 to 4;
do q=1 to dim(ques);
ques(q)=arr(q, level);
end;
output;
end;
run;
If you don't know things ahead of time like the number of levels, then you can
create this using macro code.
Hope this helps,
Amy Swinford
Trilogy Consulting
Toni Zhang wrote:
> I have to reshape a data file by PROC TRANSPOSE. However, I need to
> transpose four varialbes at once and do it for 14 times because the data
> looks like
>
> ID q301a q301b q301c q301d q302a q302b q302c q302d..q314a q314b..q314d
> 1
> 2
> 3
> ...
>
> q30a-q301d stand for each individual's response for question 301 4 different
> stores. So as q302a-q302d,...and q314a-q314d.
>
> I need to transpose q301a-q301d, q302a-q302d, ...and q314a-q314d by ID, and
> finally have a data that each person (ID) has 4 records. The data will look
> like this:
>
> =============================
> id store q301 q302 q303 q304 q305 q306....q314
> 1 1
> 1 2
> 1 3
> 1 4
> 2 1
> 2 2
> 2 3
> 2 4
> 3 ...
> ================================
>
> Instead of doing only 4 variables each time for 14 times, can I do it all at
> once with NICER SAS code? Please help. Many thanX.
>
> Tonnie.
>
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
> Share information about yourself, create your own public profile at
> http://profiles.msn.com.
|