Hi, I'm trying to automate a flow that starts from csvs that I download in outlook through a rule.
I have tried to pass a file that is saved in J: (my company's server) to the sas server (opt/sas/) but the file is passed although the content is not copied, the code I have used is this:
<
filename in "J:/xxx/xx/test/xxx.csv";
filename out "/opt/sas/data/xx/xx/xx/xx/xxx.csv";
* copy the file byte-for-byte;
data _null_;
length filein 8 fileid 8;
filein = fopen('in','I',1,'B');
fileid = fopen('out','O',1,'B');
rec = '20'x;
do while(fread(filein)=0);
rc = fget(filein,rec,1);
rc = fput(fileid, rec);
rc =fwrite(fileid);
end;
rc = fclose(filein);
rc = fclose(fileid);
run;
filename in clear;
filename out clear;
>
What I want is to transform the delimiter of these csv, later I use this code:
<
data _null_;
infile "/opt/sas/data/XXX/XX/XXX/XX/XXXX.csv" dlm='|' dsd length=ll column=cc truncover ENCODING='utf-8';
file "/opt/sas/data/XXX/XX/XXX/XXX/XX/XXX/XXXX.csv" dlm='|' ENCODING='utf-8';
do until(cc>ll);
input value ~ :$char32767. @;
if missing(value) then value ='""';
put value :$char32767. @;
end;
put;
run;
>
I have removed the paths for privacy, but what I do roughly is pass the csv from one folder to another and then change the delimiter and encoding of that file, the code block to change the encoding and delimiter works, which fails is to pass me the csv from J: to SAS.
Does anyone know how to do this in a way that works? Is it possible to do this with a proc import or something similar?
Thanks for your help
Where is the code executed? On the server or in a local session?
On a server: impossible to access J:, because this is Windows notation, and sas seems to be running on Linux/Unix.
Local session: impossible to access "/opt/..." this is a Unix/Linux pathname and won't work on a windows-server.
Solution:
On a server: maybe it is possible to mount "J", talk to the sas-admins. In this case moving the file is not necessary any longer.
Local session: you need a shared drive for servers file system, talk to the sas-admins.
Where is the code executed? On the server or in a local session?
On a server: impossible to access J:, because this is Windows notation, and sas seems to be running on Linux/Unix.
Local session: impossible to access "/opt/..." this is a Unix/Linux pathname and won't work on a windows-server.
Solution:
On a server: maybe it is possible to mount "J", talk to the sas-admins. In this case moving the file is not necessary any longer.
Local session: you need a shared drive for servers file system, talk to the sas-admins.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: