Date: Fri, 17 Nov 2006 18:18:57 -0500
Reply-To: Hari Nath <hari_s_nath@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Hari Nath <hari_s_nath@YAHOO.COM>
Subject: Re: Inserting totals from row1 to rest of the rows
Ian,
Thanks for your answer. As I had mentioned in the original post, Iam
reading a sas dataset that was originated from text files. The number
indicates the discrete count and percentages are within the paranthesis. I
need to add the totals between those and iam still not sure which totals
to insert. But atleast i got a start from your programs.
Thanks,
hari
On Fri, 17 Nov 2006 19:18:16 +0000, Ian Whitlock <iw1junk@COMCAST.NET>
wrote:
>Summary: Change the data structure
>#iw-value=1
>
>Hari,
>
>Others appear to have given you what you asked for. I am more
>interested in what you are doing and data structure. You appear
>to be reading a report and then massaging it. This looks like a
>bad idea. Let's suppose you want to read some text into a SAS
>data set to hold the equivalent information.
>
>I massaged your code a little to make it work.
>
> Data have ;
> infile cards truncover ;
> input textcol $16. cell1 :$10. cell2 :$10. cell3 :$10.
> cell4 :$10. ;
> if textcol = " " then delete ;
> cards ;
> no of subjects 2(100) 3(100) 2(100) 7(100)
> visit 1_1 1(50) 3(100) 2(100) 6(85.7)
> visit 2_1 2(100) 3(100) 2(100) 7(100)
> ;
>
>Then I decided that you really need two different data sets - one
>to hold the basic information and one for summary data. here is
>my code.
>
> data want ( keep = visit seq1-seq4 count1-count4)
> tot ( keep = visit seq1-seq4 count1-count4) ;
> length visit $ 8 seq1-seq4 count1-count4 8 ;
> set have ;
> array cell (*) cell: ;
> array seq (*) seq: ;
> array cnt (*) count: ;
> do i = 1 to dim ( cell ) ;
> seq[i] = input(scan(cell[i],1,"(" ),8.) ;
> cnt[i] = input(scan(cell[i],2,"()"),8.) ;
> end ;
> if _n_ = 1 then
> do ;
> visit = "total" ;
> output tot ;
> end ;
> else
> do ;
> visit = scan ( textcol , 2 , " " ) ;
> output want ;
> end ;
> run ;
>
>Purists might well wonder this is really a good data structure
>for the information. However, it is so much better than what was
>asked for that I do not want to go any further. Perhaps you
>should step back and ask yourself what you are doing and why.
>
>Ian Whitlock
>===============
>Date: Fri, 17 Nov 2006 12:50:50 -0500
>Reply-To: Hari Nath <hari_s_nath@YAHOO.COM>
>Sender: "SAS(r) Discussion"
>From: Hari Nath <hari_s_nath@YAHOO.COM>
>Subject: Inserting totals from row1 to rest of the rows
>Hi all,
> Here is sas dataset I have. I need to insert the no of subjects
> within
>every visit. It looks complicated for me, but can someone here
>try to help
>me with this issue....Iam using version 8.2, windows.....
>Thanks,
>hari
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>Data have ;
> input textcol $26. cell1 $10. cell2 $13. cell3 $11. cell4 $10.
> ;
> cards ;
>no of subjects 2(100) 3(100) 2(100) 7(100)
> visit 1_1 1(50) 3(100) 2(100) 6(85.7)
> visit 2_1 2(100) 3(100) 2(100) 7(100)
>;
>run ;
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>Data need ;
> input textcol $26. cell1 $10. cell2 $13. cell3 $11. cell4 $10.
> ;
> cards ;
>no of subjects 2(100) 3(100) 2(100) 7(100)
> visit 1_1 1/2(50) 3/3(100) 2/2(100) 6/7(85.7)
> visit 2_1 2/2(100) 3/3(100) 2/2(100) 7/7(100)
>;
>run;
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|