BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Abelp9
Quartz | Level 8

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

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

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.

 

View solution in original post

1 REPLY 1
andreas_lds
Jade | Level 19

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.

 

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 370 views
  • 2 likes
  • 2 in conversation