Dear All,
I have a problem concerning 32bit vs 64bit in sas. (sas 9.3 vs sas 9.4)
I am using a procedure that allows me to open a filedialog for the users of my programs. (it is really user friendly)
i didnt write it my self (lex janssens was my inspiration). (see attachement).
In 9.4 it gives me problems.
i added dlltype=32 because apparently 9.4 is 64bit and cannot compile 32bit.
the program runs but it won't save the location of the file.
giving the error : you cannot use addr but have to use addrlong.
however changing addr to addrlong gives more errors.
Does anyone has a solution for this problem. (attachement has the program)
Select a file from a pop up dialog box and list the file
requires Python
inspired by ( this is a link to this message)
https://goo.gl/eKhTYt
https://communities.sas.com/t5/Base-SAS-Programming/filedialog-sas-9-3-vs-sas-9-4/m-p/345718
Doable in R but I like Python and SAS/WPS for these kinds of problems
HAVE ( A directory with some files (chose your own directory)
==============================================================
Directory of d:/txt
fyl.txt
hex.txt
hexout.txt
myfile.txt
utf16le.txt
UtlChkFyl.txt ==> click on this one
WANT ( select and print file )
===============================
click on
UtlChkFyl.txt
And this will appear in log
%macro utlchkfyl(file);
%if %sysfunc(fileexist(&file)) ge 1 %then %do;
%let rc=%sysfunc(filename(temp,&file));
%let rc=%sysfunc(fdelete(&temp));
%end;
%else %put The file &file does not exist;
%mend utlchkfyl;
WORKING CODE (PYTHON)
=====================
fyl = tkFileDialog.askopenfilename(filetypes=[('Text files', '*.txt')]);
INVOCATION
==========
%SelDir(c:/txt);
* _ _ _
___ ___ | |_ _| |_(_) ___ _ __
/ __|/ _ \| | | | | __| |/ _ \| '_ \
\__ \ (_) | | |_| | |_| | (_) | | | |
|___/\___/|_|\__,_|\__|_|\___/|_| |_|
;
%macro SelDir(dir);
%utl_submit_py64("
import os;
import tkFileDialog;
import os;
os.chdir('&dir');
fyl = tkFileDialog.askopenfilename(filetypes=[('Text files', '*.txt')]);
fo= open ('d:/txt/fyl.txt', 'w');
fo.write(fyl+'\n');
fo.close();
");
* could also use filevar in infile;
* but I think it is worth learning and using this method;
data _null_;
if _n_=0 then do;
%let rc=%sysfunc(dosubl('
data _null_;
infile "d:/txt/fyl.txt";
input;
fylvar=strip(_infile_);
call symputx("fyl",fylvar);
run;quit;
'));
end;
infile "&fyl";
input;
put _infile_;
run;quit;
%mend SelDir;
%SelDir(d:/txt);
%macro utl_submit_py64(pgm)/des="Semi colon separated set of py commands";
* write the program to a temporary file;
filename py_pgm "%sysfunc(pathname(work))/py_pgm.py" lrecl=32766 recfm=v;
data _null_;
length pgm $32755 cmd $1024;
file py_pgm ;
pgm=&pgm;
semi=countc(pgm,';');
do idx=1 to semi;
cmd=compbl(cats(scan(pgm,idx,';')));
if cmd=:'.' then cmd=substr(cmd,2);
put cmd $char384.;
putlog cmd $char384.;
end;
run;
run;quit;
%let _loc=%sysfunc(pathname(py_pgm));
%put &_loc;
filename rut pipe "C:\Python_27_64bit/python.exe &_loc";
data _null_;
file print;
infile rut;
input;
put _infile_;
run;
filename rut clear;
filename py_pgm clear;
%mend utl_submit_py64;
thanks for the reply but we dont have python.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.