![]() | ![]() | ![]() | ![]() | ![]() |
Note:
For detailed information regarding object dot programming
in the DATA step, please refer to
SAS 9.2 Language
Reference: Concepts, Using DATA Step Component Objects.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
/************************************************************************************/
/* This program removes the top and bottom 10% of the data from each BY-Group. */
/* Note that the values of the variable J need to be unique within each BY-Group. */
/************************************************************************************/
data test;
input i j;
datalines;
1 .08
1 2
1 7
1 9
1 12
1 13
1 22
1 14
1 12.2
1 12.1
1 .09
1 2.1
1 7.1
1 9.1
1 12.12
1 13.1
1 22.1
1 14.1
1 12.3
1 12.4
2 100
2 10
2 11
2 12
2 9
2 101
2 10.1
2 11.1
2 12.1
2 9.1
;
data final;
/* Declare and instantiate a single hash table which will */
/* contain the observations, ordered ascending, from the */
/* data set TEST. */
if _n_=1 then do;
declare hash h(ordered:'a');
declare hiter hit('h');
h.definekey('j');
h.definedata('i','j');
h.definedone();
end;
/* Load all the observations of one BY-Group from the data set */
/* TEST into the hash table H. */
do until (last.i);
set test;
by i;
rca=h.add();
end;
/* Calculate the number of observations in the BY-Group and the */
/* number of observations that need to be deleted. */
byct=h.num_items;
obs2del=round((byct-byct * .8)/2);
/* Iterate through the hash table and output the middle 80% of */
/* the observations. */
rcf=hit.first();
do x=1 to byct;
if x gt obs2del and x le byct-obs2del then output;
rch=hit.next();
end;
/* Clear out the hash table. */
do while (hit.next() = 0);
rc=h.remove(key:_j);
_j=j;
end;
keep i j;
run;
proc print;
run;
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
Obs i j 1 1 2.00 2 1 2.10 3 1 7.00 4 1 7.10 5 1 9.00 6 1 9.10 7 1 12.00 8 1 12.10 9 1 12.12 10 1 12.20 11 1 12.30 12 1 12.40 13 1 13.00 14 1 13.10 15 1 14.00 16 1 14.10 17 2 9.10 18 2 10.00 19 2 10.10 20 2 11.00 21 2 11.10 22 2 12.00 23 2 12.10 24 1 22.10 25 2 100.00
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step SAS Reference ==> Component Objects ==> hash object ==> ADD SAS Reference ==> Component Objects ==> hash object ==> DEFINEDATA SAS Reference ==> Component Objects ==> hash object ==> DEFINEDONE SAS Reference ==> Component Objects ==> hash object ==> DEFINEKEY SAS Reference ==> Component Objects ==> hash object ==> NUM_ITEMS Attribute SAS Reference ==> Component Objects ==> hash object ==> REMOVE SAS Reference ==> Component Objects ==> hash iterator object ==> FIRST SAS Reference ==> Component Objects ==> hash iterator object ==> NEXT |
| Date Modified: | 2005-12-08 11:34:47 |
| Date Created: | 2005-11-23 14:49:00 |
| Product Family | Product | Host | SAS Release | |
| Starting | Ending | |||
| SAS System | Base SAS | Tru64 UNIX | 9.1 TS1M0 | n/a |
| Linux | 9.1 TS1M0 | n/a | ||
| 64-bit Enabled Solaris | 9.1 TS1M0 | n/a | ||
| HP-UX IPF | 9.1 TS1M0 | n/a | ||
| 64-bit Enabled HP-UX | 9.1 TS1M0 | n/a | ||
| 64-bit Enabled AIX | 9.1 TS1M0 | n/a | ||
| Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M0 | n/a | ||
| OpenVMS Alpha | 9.1 TS1M0 | n/a | ||
| z/OS | 9.1 TS1M0 | n/a | ||




