LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (November 2006, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 8 Nov 2006 21:23:25 +0000
Reply-To:     toby dunn <tobydunn@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         toby dunn <tobydunn@HOTMAIL.COM>
Subject:      Re: how to get every m observation from one data set
Comments: To: chenming@GMAIL.COM
In-Reply-To:  <52fcff540611081308w7fb3fd84v4ffd5331a0eabb11@mail.gmail.com>
Content-Type: text/plain; format=flowed

Not very elegant but does he job, I will leave it to you to refactor .

Data Need ( Drop = A Cnt ) ; Set One Nobs = Nobs ; Array Var ( 3 ) Var1-Var3 ; Retain Var1 Var2 Var3 ;

Cnt + 1 ;

Var( Cnt ) = A ;

If ( Cnt = 3 ) Or ( _N_ = Nobs ) Then Do ; Output ; Cnt = 0 ; Var1 = 0 ; Var2 = 0 ; Var3 = 0 ; End ;

Run ;

Proc print Data = Need ; Run ;

Toby Dunn

Quickly, bring me a beaker of wine, so that I may wet my mind and say something clever. Aristophanes

Wise people, even though all laws were abolished, would still lead the same life. Aristophanes

You should not decide until you have heard what both have to say. Aristophanes

From: Ming Chen <chenming@GMAIL.COM> Reply-To: Ming Chen <chenming@GMAIL.COM> To: SAS-L@LISTSERV.UGA.EDU Subject: how to get every m observation from one data set Date: Wed, 8 Nov 2006 16:08:02 -0500

hi

Here is the sample data:

data one; input a; datalines; 1 2 3 4 5 6 7 8 9 10 ;

Here is the data I want for every 3 obs: 1 4 7 2 5 8 3 6 9 10 0 0

I set the data to 0 if no such position.

I tried to transpose first then use array. But the code is very complicated and can not deal with the irregular data.

Thanks in advance.

Ming

_________________________________________________________________ Find a local pizza place, music store, museum and more…then map the best route! http://local.live.com?FORM=MGA001


Back to: Top of message | Previous page | Main SAS-L page