Date: Tue, 16 Mar 2010 18:40:43 -0500
Reply-To: "Data _null_;" <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Data _null_;" <iebupdte@GMAIL.COM>
Subject: Re: Pointer of SAS Read In -- Re: [SAS-L] Fortran to SAS
In-Reply-To: <613529.72786.qm@web112104.mail.gq1.yahoo.com>
Content-Type: text/plain; charset=ISO-8859-1
You can't output to row1 because it is gone. You can however read the
variable into and enumerated variable list and then output.
data a;
infile cards;
input (iyrst imst idst iyrnd imnd idnd ndays)(5.) indx 10. ;
array _SST[40];
array _ICE[40] $3.;
input (_SST[*])(4.) / (_ICE[*])($char3.);
do _n_ = 1 to 40;
SST=_sst[_n_];
ICE=_ice[_n_];
output;
end;
drop _:;
cards;
2010 1 1 2010 1 31 311115100345
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
107 107 107 108 110 111 111 111 110 109 108 107 106 104 103 100 99 96 93 91
001002003004005006007008009010011012013014015016017018019020021022023024025026
027028029030031032033034035036037038039040
;
run;
proc print;
run;
On 3/16/10, Andrew Wang <hellangel_987@yahoo.com> wrote:
> I have to Thank Mat Zack, Nathan Wooding, F.J. Kelly, and Sterling Paramore to help me understand the FORTRAN code.
>
> Now it come to SAS question, the sample (shortened) SAS code is below. The data ( under CRADS ) has five lines, the 2nd and 3rd lines are the 40 observations of SST, each has length 4; the 4th and 5th lines are the 40 observations of ICE (character of length 3) .
>
> If read-in correctly, the variables SST and ICE should appear in pairs that the resulting SAS dataset should have only 40 rows. But my code somehow stacks variable ICE under SST, rendering a dataset of 80 rows
>
> I believe this is a pointer problem, how could I let SAS know that after read-in all the 40 SST data, the first value of ICE should be output to row 1 instead of row 41?
>
> Thank You
>
> Andy
>
>
> data a;
> input iyrst 5. imst 5. idst 5. iyrnd 5. imnd 5. idnd 5. ndays 5. indx 10. ;
> do i=1 to 40;
> input SST 4.@@;
> output;
> end;
> do i=1 to 40;
> input ICE $CHAR3. @@;
> output;
> end;
> cards;
> 2010 1 1 2010 1 31 311115100345
> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
> 107 107 107 108 110 111 111 111 110 109 108 107 106 104 103 100 99 96 93 91
> 001002003004005006007008009010011012013014015016017018019020021022023024025026
> 027028029030031032033034035036037038039040
> ;
> run;
>
>
>
>
|