Go Back   Rhinocerus > Newsgroup > Newsgroup comp.soft-sys.sas

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 12-23-2004, 09:21 PM
Jack Hamilton
Guest
 
Posts: n/a
Default Re: Order of FIRST. / LAST. variables in PDV

Very clever idea!

You'll need to make sure that there's only one BY list in the data
step, or at least that the one you care about comes first.

=====
466 data test (index=(cba=(c b a)));
467 retain a b c d 0;
468 do a = 0, 1, 2;
469 do b = 3, 4, 5;
470 do c = 6, 7, 8;
471 d = 9;
472 output;
473 end;
474 end;
475 end;
476
477 stop;
478
479 run;

NOTE: The data set WORK.TEST has 27 observations and 4 variables.
NOTE: Composite index cba has been defined.

480
481 data _null_;
482
483 set test;
484 by a b d;
485
486 array first[*] first: ;
487
488 length x $40.;
489
490 if _n_ = 1 then
491 do I=1 to dim(first);
492 * Retrieve name minus 'FIRST.';
493 x = substr(vname(first[i]), 7);
494 put 'INFO: ' x=;
495 end;
496
497 run;

INFO: x=a
INFO: x=b
INFO: x=d
NOTE: There were 27 observations read from the data set WORK.TEST.

498
499 data _null_;
500
501 if 0 then
502 do;
503 set test;
504 by c b a;
505 end;
506
507 set test;
508 by a b d;
509
510 array first[*] first: ;
511
512 length x $40.;
513
514 if _n_ = 1 then
515 do I=1 to dim(first);
516 * Retrieve name minus 'FIRST.';
517 x = substr(vname(first[i]), 7);
518 put 'INFO: ' x=;
519 end;
520
521 run;

INFO: Index cba selected for BY clause processing.
INFO: x=c
INFO: x=b
INFO: x=a
INFO: x=d
NOTE: There were 1 observations read from the data set WORK.TEST.
NOTE: There were 27 observations read from the data set WORK.TEST.
=====

Does the storage optimization that SAS sometimes applies to data sets
apply to the PDV as well? I'm not sure where I'd look that up.



--
JackHamilton@FirstHealth.com
Manager, Technical Development
Metrics Department, First Health
West Sacramento, California USA

Coelum, non animum mutant, qui trans mare currunt.


>>> "m n" <iced_phoenix_news@YAHOO.COM> 12/23/2004 1:13 PM >>>

Dear SAS-L,

Does anyone know if there is a (*documented*)
guarantee that the order of the FIRST./LAST. variables
in the PDV will be the same as the order of variables
in the expanded by-variable list?

For instance:

data &OUT;
set &DATA;
by &COMPLICATED_BY_VARIABLE_LIST;

array first[*] first: ;

do I=1 to dim(first);
* Retrieve name minus 'FIRST.';
x = substr(vname(first[i]), 7);
put x=;
end;
run;

Is there any guarantee that the FIRST. variable
ordering will line up with the expanded by-variable
ordering (so that I can expand the complicated
variable list)?

This works in my experiments, but I can't find
documentation about this, and so I hate to rely upon
"seems to work" rather than "guaranteed to work".

Thanks for your help!

Matt

<ASIDE> The above code breaks if you have variables in
the data step that begin with 'First' (other than the
'First.' variables). SAS does not allow First.:,
unfortunately. </ASIDE>





__________________________________
Do you Yahoo!?
Send a seasonal email greeting and help others. Do good.
yahoo.com" target="_blank">http://celebrity.mail.yahoo.com


"MMS <firsthealth.com>" made the following annotations.
------------------------------------------------------------------------------
This message, including any attachments, is intended solely for the use
of the named recipient(s) and may contain confidential and/or
privileged information. Any unauthorized review, use, disclosure or
distribution of this communication(s) is expressly prohibited.
If you are not the intended recipient, please contact the sender by
reply e-mail and destroy any and all copies of the original message.
Thank you.
================================================== ============================
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Massive Do Loop in macro - revisited Ya Huang Newsgroup comp.soft-sys.sas 0 03-30-2007 10:20 PM
Re: How to put the variables in a certain order? Bob Abelson Newsgroup comp.soft-sys.sas 0 05-16-2006 06:09 PM
Re: How to order variables in a SAS data set? Fehd, Ronald J. PHPPO Newsgroup comp.soft-sys.sas 0 01-19-2005 08:03 PM
Re: How to order variables in a SAS data set? Jack Hamilton Newsgroup comp.soft-sys.sas 1 01-19-2005 06:53 PM
Re: How to order variables in a SAS data set? toby dunn Newsgroup comp.soft-sys.sas 0 01-19-2005 06:34 PM



All times are GMT. The time now is 07:08 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.