(: file: pop_1998_by_year.xq date: 29-July-2010 author: Gary Lewis purpose: Identifies institutions to include in the warehouse for the year 1998. The filters are those used by NCES in Table 265 of the Digest of Education Statistics 2009. notes: 1. Filters vary by IPEDS survey years. This program uses those appropriate for survey year 1998. 2. The xml output from this program gets combined with the xml from other surveys years in the XQuery program pop_combined_all_years.xq. usage: Run program from its path location. example: zorba -f -q pop_1998_by_year.xq -o pop_1998.xml -z indent=yes :) { for $i in fn:doc("../xml/metadata/ipedsData.xml")/data/file[@type = "xml"] let $year := xs:integer($i/@year), $path := $i/@path, $file := $i/@name, $xmlFile := concat($path, $file) where $year = 1998 order by $year descending return { for $x in fn:doc($xmlFile)/data/record let $unitid := $x/@unitid, $fips := if ($x/@fips = "") then -999 else $x/@fips, $sector := if ($x/@sector = "") then -999 else $x/@sector, $hdegoffr := if ($x/@hdegoffr = "") then -999 else $x/@hdegoffr, $opeflag := if ($x/@opeflag = "") then -999 else $x/@opeflag where $fips > 0 and $fips <= 56 and $sector > 0 and $hdegoffr > 0 and $opeflag = (1,2,3) return } }