(: OBSOLETED! date: 27-August-2010 author: Gary Lewis note: whPop.xml now contains all IPEDS institutions rather than the 5602 that appear in Table 265. This provides greater long-term flexibility in population definition. note: The procedure for verifying data moved to staging and the warehouse is now generalized so it does not require variable specific XQuery programs. See: freq_1var_stgPop_by_year.xq freq_1var_stg2whPop_by_year.xq freq_1var_whPop_by_year.xq :) (: file: verify_whPop_freq_1var_1year.xq date: 09-August-2010 author: Gary Lewis purpose: Frequency distribution for a specified IPEDS variable in a specified survey year, filtered to include only those institutions in the warehouse population (ie, pop_distinct_institutions.xml). notes: 1. The output of this program can be used to compare with frequency distributions from whPop.xml to help ensure that variables in whPop.xml are being built correctly. 2. For example, if var=control and year=2007 in this program, the output will be an XML file showing the frequency distribution of the IPEDS control variable in the survey year 2007, but only for those institutions in pop_distinct_institutions.xml. This frequency distribution can be compared with rControl_freq.xml (produced by running rControl_freq.xq). The frequency distributions in the two XML should match. 3. Output goes to the screen. usage: Run this program from its path location. example: zorba -e var:="control" -e year:="2007" -f -q verify_whPop_freq_1var_1year.xq -z indent=yes :) declare variable $var external; declare variable $year external; { let $x := fn:doc("../xml/metadata/ipedsData.xml")/data/file[@year = $year][@type = "xml"], $xmlFile := concat($x/@path, $x/@name) for $i in fn:doc($xmlFile)/data/record let $unitid := $i/@unitid, $dataType := fn:doc("../xml/metadata/ipedsVars_metadata.xml")/variables/var[@name = $var]/detail[@year = $year]/@dataType, $value := using $dataType, $var, $i eval{concat('if ($dataType = "N") then (if ($i/@',$var,' = "") then -999 else xs:integer($i/@',$var,')) else $i/@',$var)}, $label := fn:doc("../xml/metadata/ipedsVars_metadata_codes.xml")/variables/var[@name = $var][@year = $year]/code[@value = $value]/@label where $unitid = fn:doc("../xml/warehouse/pop_distinct_institutions.xml")/population/inst/@unitid group by $value, $label order by $value return }