(: file: list_vars_by_numYears_1lastYear.xq date: 01-September-2010 author: Gary Lewis purpose: Lists IPEDS directory variables by the number of years that the variables have appeared in IPEDS surveys. Includes name, number of years, first year, last year, and description of the variable in the last year. Used to help identify variables for possible inclusion in the data warehouse. Includes only those variables with a specified last year. usage: Run from path where program is located. example: zorba -e lastYR:="2008" -f -q list_vars_by_numYears_1lastYear.xq -o list_vars_by_numYears_lastYear_2008.xml -z indent=yes :) declare variable $lastYR external; { let $tmp1 := for $i in fn:doc("../xml/metadata/ipedsVars_metadata.xml")/variables/var let $name := $i/@name, $numYears := xs:integer($i/@numYears), $firstYear := min(fn:doc("../xml/metadata/ipedsVars_metadata.xml")/variables/var[@name = $name]/detail/@year), $lastYear := max(fn:doc("../xml/metadata/ipedsVars_metadata.xml")/variables/var[@name = $name]/detail/@year), $lastYrDesc := fn:doc("../xml/metadata/ipedsVars_metadata.xml")/variables/var[@name = $name]/detail[@year = $lastYear]/@description order by $numYears descending, $name ascending return return for $j in $tmp1[@lastYear = $lastYR] return }