You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1012 B
Plaintext

program define tosas,eclass
version 10.0
syntax [varlist] [if] [in] [,Name(string) pgm(string) Batch]
preserve
if "`if'"!=""|"`in'"!="" {
qui keep `if' `in'
}
local dir=c(tmpdir)
tempfile tosasfile totsasfile
qui outsheet `varlist' using "`tosasfile'.txt",replace
qui outsheet `varlist' using "d:\essai.txt",replace
if "`name'"=="" {
local name stata
}
drop _all
qui set obs 1000
qui gen txt=""
qui replace txt="PROC IMPORT OUT=WORK.`name' DATAFILE='`tosasfile'.txt' DBMS=TAB REPLACE;GETNAMES=YES;DATAROW=2; RUN;" in 3
qui replace txt="`pgm'" in 4
qui outsheet txt using "`tosasfile'_pgmsas.txt", replace nonames noquote
if "`batch'"!="" {
shell "C:\Program Files\SAS\SASFoundation\9.3\sas.exe" "`tosasfile'_pgmsas.txt" -print "`tosasfile'.lst" -nolog
view "`tosasfile'.lst"
}
else {
shell "C:\Program Files\SASHome\SASFoundation\9.3\core\sasexe\SASOACT.EXE" action=Submit datatype=SASFile filename="`tosasfile'_pgmsas.txt" progid=SAS.Application.903
}
restore
end