SAS Samples Assurant Health SAS Users 11/18/2008 Irvin Snider
Systematic Sample From Known Number of Observations
data  work.subset; do pickit=1 to 395 by 15; set sashelp.shoes point=pickit; output; end; stop; run ;
$1,468 $181,739 $54,791 4 Madrid Men's Dress Western Europe 16 $9,845 $595,118 $175,694 12 Heidelberg Men's Casual Western...
Systematic Sample From Unknown Number of Observations
data  work.subset; do pickit=1 to totobs by 25; set sashelp.shoes point=pickit nobs=totobs; output; end; stop; run ;
Random Sample with Replacement
data  work.rsubset (drop=i sampsize); sampsize = 10; do i=1 to sampsize; pickit=ceil(ranuni(0)*totobs); set sashelp.shoes ...
Random Sample without Replacement
data  work.rsubset (drop=obsleft sampsize); sampsize=10; obsleft=totobs; do while (sampsize > 0); pickit + 1; if ranuni(0)...
Permuted Blocks Randomization for Equal Allocation to Treatments A and B
<ul><li>data  values; </li></ul><ul><li>samplesize= 48 ; </li></ul><ul><li>blocksize= 6 ; </li></ul><ul><li>run ; </li></u...
End <ul><li>Point= </li></ul><ul><li>STOP; </li></ul><ul><li>NOBS= </li></ul><ul><li>RANUNI(seed) </li></ul><ul><li>CEIL(a...
Sources <ul><li>SAS Certification Prep Guide </li></ul><ul><li>Advanced Programming for SAS9 </li></ul><ul><li>Pages 450-4...
Thank You
Upcoming SlideShare
Loading in...5
×

Sas Samples

639
-1

Published on

Published in: Education, Lifestyle, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
639
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
28
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • SAS Sampling Presenting five sampling examples and five pieces of code: 1. Systematic sample from known number of observations 2. Systematic sample from unknown number of observations 3. Random sample with replacement 4. Random sample without replacement 5. Permuted blocks randomization Why am I presenting this? SAS by default reads observations on a data set sequentially 1. May make life easier to get a sample instead of going against the entire data set. Especially when you are concerned with the accuracy of the data. 2. There may be a need for sampling in your area.
  • Sas Samples

    1. 1. SAS Samples Assurant Health SAS Users 11/18/2008 Irvin Snider
    2. 2. Systematic Sample From Known Number of Observations
    3. 3. data work.subset; do pickit=1 to 395 by 15; set sashelp.shoes point=pickit; output; end; stop; run ;
    4. 4. $1,468 $181,739 $54,791 4 Madrid Men's Dress Western Europe 16 $9,845 $595,118 $175,694 12 Heidelberg Men's Casual Western Europe 15 $3,039 $226,678 $70,790 15 Seattle Boot United States 14 $10,194 $754,157 $293,313 37 Chicago Women's Dress United States 13 $361 $39,256 $8,365 22 Montevideo Sport Shoe South America 12 $939 $23,822 $11,759 8 Buenos Aires Slipper South America 11 $1,449 $110,179 $31,503 21 Manila Boot Pacific 10 $1,278 $158,688 $42,760 6 Auckland Women's Dress Pacific 9 $43 $1,836 $449 2 Al-Khobar Sport Shoe Middle East 8 $3,983 $520,271 $127,033 11 Moscow Slipper Eastern Europe 7 $1,012 $78,950 $30,157 3 Mexico City Men's Dress Central America/Caribbean 6 $20,470 $671,837 $353,361 25 Vancouver Men's Casual Canada 5 $488 $54,677 $12,601 2 Calgary Women's Dress Canada 4 $844 $66,017 $16,282 25 Nairobi Boot Africa 3 $1,565 $130,025 $39,452 12 Johannesburg Slipper Africa 2 $769 $191,821 $29,761 12 Addis Ababa Boot Africa 1 Returns Inventory Sales Stores Subsidiary Product Region Obs
    5. 5. Systematic Sample From Unknown Number of Observations
    6. 6. data work.subset; do pickit=1 to totobs by 25; set sashelp.shoes point=pickit nobs=totobs; output; end; stop; run ;
    7. 7. Random Sample with Replacement
    8. 8. data work.rsubset (drop=i sampsize); sampsize = 10; do i=1 to sampsize; pickit=ceil(ranuni(0)*totobs); set sashelp.shoes point=pickit nobs=totobs; output; end; stop; run ;
    9. 9. Random Sample without Replacement
    10. 10. data work.rsubset (drop=obsleft sampsize); sampsize=10; obsleft=totobs; do while (sampsize > 0); pickit + 1; if ranuni(0)<sampsize/obsleft then do; set sashelp.shoes point=pickit nobs=totobs; output; sampsize=sampsize- 1 ; end; obsleft=obsleft-1; end; stop; run ;
    11. 11. Permuted Blocks Randomization for Equal Allocation to Treatments A and B
    12. 12. <ul><li>data values; </li></ul><ul><li>samplesize= 48 ; </li></ul><ul><li>blocksize= 6 ; </li></ul><ul><li>run ; </li></ul><ul><li>data random; </li></ul><ul><li>set values; </li></ul><ul><li>nblocks=round(samplesize/blocksize); </li></ul><ul><li>na=round(blocksize/ 2 ); </li></ul><ul><li>nb=blocksize-na; </li></ul><ul><li>do block= 1 to nblocks by 1 ; </li></ul><ul><li>nna= 0 ; </li></ul><ul><li>nnb= 0 ; </li></ul><ul><li>do i= 1 to blocksize; </li></ul><ul><li>subject=i+((block- 1 )*blocksize); </li></ul><ul><li>if nna=na then treatment=&quot;B&quot;; </li></ul><ul><li>if nnb=nb then treatment=&quot;A&quot;; </li></ul><ul><li>else do; </li></ul><ul><li>aprob=(na-nna)/(na+nb-nna- nnb); </li></ul><ul><li>u=ranuni( 0 ); </li></ul><ul><li> if ( 0 <=u<=aprob) then do; </li></ul><ul><li>treatment=&quot;A&quot;; </li></ul><ul><li>nna=nna+ 1 ; </li></ul><ul><li>end; </li></ul><ul><li> if (aprob<u<= 1 ) then do; </li></ul><ul><li>treatment=&quot;B&quot;; </li></ul><ul><li>nnb=nnb+ 1 ; </li></ul><ul><li>end; </li></ul><ul><li>end; </li></ul><ul><li>keep subject treatment; </li></ul><ul><li>output; </li></ul><ul><li>end; </li></ul><ul><li>end; </li></ul><ul><li>run ; </li></ul><ul><li>proc print data=random; </li></ul><ul><li>id subject; </li></ul><ul><li>var treatment; </li></ul><ul><li>title &quot;Randomization Plan for Equal </li></ul><ul><li>Allocation to Treatments A and B&quot;; </li></ul><ul><li>run ; </li></ul>
    13. 13. End <ul><li>Point= </li></ul><ul><li>STOP; </li></ul><ul><li>NOBS= </li></ul><ul><li>RANUNI(seed) </li></ul><ul><li>CEIL(argument) </li></ul><ul><li>DO WHILE loop </li></ul>
    14. 14. Sources <ul><li>SAS Certification Prep Guide </li></ul><ul><li>Advanced Programming for SAS9 </li></ul><ul><li>Pages 450-458 </li></ul><ul><li>Penn State University </li></ul><ul><li>STAT 509 Clinical Trials </li></ul><ul><li>Lesson 8 </li></ul>
    15. 15. Thank You
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×