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 (July 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 16 Jul 2009 09:47:55 -0700
Reply-To:     "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Subject:      Re: separating observations in a dataset
Comments: To: Randall Powers <powers_r@BLS.GOV>
In-Reply-To:  A<200907161617.n6GAlXS6007375@malibu.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"

Hi Randall,

Several ways to do this, here is one approach:

data sample(drop=i); length type $5; do i = 1 to 4; type = 'iter'; output; end; type = 'final'; output; do i = 1 to 107; type = 'iter'; output; end; type = 'final'; output; do i = 1 to 22; type = 'iter'; output; end; type = 'final'; output; do i = 1 to 111; type = 'iter'; output; end; type = 'final'; output; run;

data result; set sample; retain run_number 1; retain counter 0; counter + 1; if type eq 'final' or counter eq 102 then do; desired_obs = 'Y'; * flag it ; output; counter = 0; * reset ; run_number + 1; * reset ; end; else output; run;

Hope this is helpful.

Mark Terjeson Investment Business Intelligence Investment Management & Research Russell Investments 253-439-2367

Russell Global Leaders in Multi-Manager Investing

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Randall Powers Sent: Thursday, July 16, 2009 9:18 AM To: SAS-L@LISTSERV.UGA.EDU Subject: separating observations in a dataset

Hello All,

There must be a way to do this!

I have a dataset with variable "type". The values for type are either "iter" or "final". There are numerous (10,000+) observations.

The file is a collection of the parameters from a run of proc nlin (probably not pertinent to my question). "Final" represents the final value of of a converging nlin program. "Iter" means that it is an interation. The program will either converge at or before 102 observations, or it will stop and thus the 102nd observation in the sequence is still "Iter".

What I want to do is output all of the "final"s to file A, and output of the 102nd "iter" for those that don't reach a final value by that point, to file B. How do I do this?

Thus, an example of my starting dataset file would be:

iter (start of run #1) iter iter iter final iter (start of run #2) iter . . . . (102nd) iter (and in this case 107th overall observation)) iter (this would be start of run #3) iter iter iter iter iter iter final iter (start of run #4...there are 1000 runs total)


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