How to write batch file in SAS that automates the opening of files? -


i assigned task don’t know start. here’s context:

there’s variable in data, var1, indicating directory bunch of image files. observation 1, var1 may d:\project\data\images\image1.tiff , on. of course, image files exist in computer.

what need figure out sas program(s) , later run them automatically using batch file. when batch file runs, will, in way, opens image files 1 one. “one one”, mean firsts open 1 image file and, upon closing file, opens next image file until end of list.

better yet, batch file make copy of original image files , put them in folder (e.g., d:\project\data\temp images) before opening them. make sure original data left untouched.

do know how can write such program in sas? given following spss file reference, job nicely described. don’t know enough spss understand every detail how works. 2 variables dir5 , tiff5 specify location of image files, , variables scqid , ohhscqid id variables.

    string out2 (a200).      compute out2=concat('copy "', ltrim(rtrim(dir5)),"\", tiff5, '"',' "c:\temp\temp.tiff"').      write outfile='e:\data\outcome.bat'/'@echo scq id  ' ohhscqid .      write outfile='e:\data\outcome.bat'/out2.      write outfile='e:\data\outcome.bat'/'@"c:\program files\microsoft office\office14\ois.exe" "c:\temp\temp.tiff"'.  execute. 

i did homework , figured out 1 way works want to. not optimal way programmingly though, idea this.

data batwide;set have; echo = '@echo scq id '||ohhscqid; predir = 'copy '||'"'||strip(dir5)||strip('\')||strip(tiff5)||strip('"'); preexec = '@'||strip('"')||strip('c:\program files\microsoft office\office14\ois.exe')||strip('"'); temp = '"'||strip('c:\temp\temp.tiff')||strip('"'); run;  data batwide; set batwide; dir = catx(' ',predir,temp); exec = catx(' ',preexec,temp); run;  data batlong;set batwide; format bat $200.; bat = echo;output; bat = dir;output; bat = exec;output; keep bat; run;  data _null_; set batlong; file "e:\sas codes , files\batchfile.bat"; put bat; run; 

sounds asking how generate series of os commands text file? can use data step that.

if want test if specified files exist use fileexist() function.

so if have sas dataset name have variable named var1 contains filename want program this:

data _null_;   set have ;   file 'e:\data\outcome.bat';   if fileexist(var1) do;     target=catx('\','d:\project\data\temp images',scan(var1,-1,'\'));     put 'copy ' var1 :$quote. target :$quote. ;     put '"c:\program files\microsoft office\office14\ois.exe" ' target :$quote.;   end;   else putlog 'warning: file not found. ' var1=; run; 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -