*! mfilegr.ado  v1.1.0  July 22 1999  Phil Ryan
program define mfilegr
version 6
#delimit ;
syntax varlist (min=2 max=2 numeric),IDvar(string)
 UNIT(string) [VIEW *];
#delimit cr
tokenize `varlist'
local yvar `1'
local xvar `2'
if "`view'" == "view" {
set more on
local more "more"
set graphics on
}
else {
local more ""
set graphics off
}
tempvar  strID tempID grp
qui {
gen str1 `strID' = ""
replace `strID' = string(`idvar')
encode `strID', gen(`tempID')
egen `grp'= group(`tempID')
summ `grp'
local numgrp = r(max)
local i 1
while `i' <= `numgrp' {
local gname: label `tempID' `i'
#delimit ;
graph `yvar' `xvar' if `grp'== `i', b1("`unit' #`gname'")
 sav(`gname', replace) `options';
#delimit cr
if `i' < `numgrp' {
`more'
}
local i = `i'+1
}
}
set graphics on
set more on
end
exit