[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Re: Matrix Manipulation (Data Step)
From:       Howard Schreier <Howard_Schreier () ITA ! DOC ! GOV>
Date:       2003-06-30 11:46:46
[Download RAW message or body]

Or run back-to-back PROC TRANSPOSE steps:

   proc transpose data=xx
    out=long(drop=_name_ where=(not missing(col1)));
   by month cell notsorted;
   run;

   proc transpose data=long out=yy(drop=_name_) prefix=v;
   by month cell notsorted;
   var col1;
   run;

On Sun, 29 Jun 2003 15:29:32 -0700, Huang, Ya <yhuang@AMYLIN.COM> wrote:

>Here is a two steps solution, may be less efficient,
>but quite easy to understand. The idea is very simple
>and straightforward: write the data out as a space
>delimited text file, and read it back again with
>option missover. Make sure that missing=' ' options
>is used before write it out, so that missing will not
>be a '.' in the text file to 'occupy' the fields:
>
>data xx;
>input month   cell   v1    v2    v3    v4;
>cards;
>200101   1     10     11   13    14
>200101   2     5      8     8    10
>200101   3     2      23    5     7
>200102   1     .      1     2     3
>200102   2     .      2     5     6
>200102   3     .      12    5     2
>200103   1     .      .     3     4
>200103   2     .      .     4     7
>200103   3     .      .     2     2
>;
>
>options missing=' ';
>filename temp temp;
>
>data _null_;
> set xx;
>file temp;
>put month cell v1 v2 v3 v4;
>run;
>
>data yy;
>infile temp missover;
>input month cell v1 v2 v3 v4;
>run;
>
>proc print;
>run;
>--------------
>
>  month    cell    v1    v2    v3    v4
>
> 200101      1     10    11    13    14
> 200101      2      5     8     8    10
> 200101      3      2    23     5     7
> 200102      1      1     2     3
> 200102      2      2     5     6
> 200102      3     12     5     2
> 200103      1      3     4
> 200103      2      4     7
> 200103      3      2     2
>
>Kind regards,
>
>Ya Huang
>
>-----Original Message-----
>From: jack quinn [mailto:jack_xiao@MAIL.COM]
>Sent: Sunday, June 29, 2003 1:20 PM
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Matrix Manipulation (Data Step)
>
>
>Hi, guys, I have a dataset as below:
>month   cell   v1    v2    v3    v4
>200101   1     10     11   13    14
>200101   2     5      8     8    10
>200101   3     2      23    5     7
>200102   1     .      1     2     3
>200102   2     .      2     5     6
>200102   3     .      12    5     2
>200103   1     .      .     3     4
>200103   2     .      .     4     7
>200103   3     .      .     2     2
>
>I want to have an upper matrix like this:
>month   cell   v1    v2    v3    v4
>200101   1     10     11   13    14
>200101   2     5      8     8    10
>200101   3     2      23    5     7
>200102   1     1      2     3     .
>200102   2     2      5     6     .
>200102   3     12     5     2     .
>200103   1     3      4     .     .
>200103   2     4      7     .     .
>200103   3     2      2     .     .
>
>I don't have SAS/IML so I have use data step to implement. Any idea?
>
>
>--
>__________________________________________________________
>Sign-up for your own FREE Personalized E-mail at Mail.com
>http://www.mail.com/?sr=signup

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic