text: /******************************************************************************************************************/
  /* Purpose:  (1) Typecast transform & Generate Stratified, Unbalanced, Random Samples for each year for ingestion */
  /*               + (2) Union all the samples for the interim dataset for additional wrangling with pandas         */                                                                                           */
  /*                                                                                                                */
  /* Author: Blake Zenuni, Summer 2019                                                                              */
  /* Date Created:  Aug 1, 2019                                                                                     */
  /* Last Modified: Aug 29, 2019                                                                                    */
  /*                                                                                                                */
  /******************************************************************************************************************/
  
  
  /*---------------------------------------------------------------------------------------------------------*/
        --> NB: Latin abbreviation for NOTA BENE, meaning "note well" <--
  /*---------------------------------------------------------------------------------------------------------*/
  
  
   -- NB1: In this SQL script, stratified random samples are unbalanced for outcomes (see script 04b for balanced).
  
   -- NB2: This random sample subset of the data is stratified by median household income:
         --> i.   We divide the population into different household median income subgroups, or strata;
         --> ii.  We apply statistical measurements of perentiles validate our strata (see below in CTEs);
         --> iii. Random samples are taken from each percentile in proportion to the population, from each of the strata.
  
      --> Documentation:
               --http://www.wagonhq.com/sql-tutorial/calculating-percentiles-sql
               --https://blog.usejournal.com/creating-an-unbiased-test-set-for-your
  --                     -model-using-stratified-sampling-technique-672b778022d5
  
  
  
  
  /*
  
       NB: AFTER MUCH EFFORT IN OUR DATA WRANGLING, WE DETERMINED A MEASURED EXTRACT, TRANSFORM, LOAD METHODOLOGY,
           ALONG WITH AN UNWEIGHTED RANDOM SAMPLING TECHNIQUE WAS STATISTICALLY SUFFICENT FOR OUR PROJECT.
         A STRATIFIED RANDOM SAMPLING SHOULD BE CONSIDERED FOR FURTHER WORK & FURTHER IMPLICATIONS.
  */
  
  /*========================== 04b. Stratified Random Samples for HMDA 2009-2010 =============================*/
  /*============================================= END 04b - SQL Script  ================================================*/
  
  