BookmarkSubscribeRSS Feed
Abelp9
Quartz | Level 8

Hello everyone, I'm trying to automatically change the delimiter of a csv file that is in a certain path (in J:, the local server of my company) and leave it in the SAS server.

 

It turns out that when I run this code it works for me:

data _null_;
infile "/opt/sas/data/xxx/xx/xx/Folder1/xxxx.csv" dlm='|' dsd length=ll column=cc truncover ENCODING='utf-8';
file "/opt/sas/data/xxx/xxx/xxx/Folder1/Source/xxxx.csv" dlm='|' ;
do until(cc>ll);
input value ~ :$char32767. @;
if missing(value) then value ='""';
put value :$char32767. @;
end;
put;
run;

 

Since I take the csv file from a folder in J and put it in another folder in J like that, doesnt works:

data _null_;
infile "J:\xxxx\xxx\xxxxx\xxxxx.csv" dlm='|' dsd length=ll column=cc truncover ENCODING='utf-8';
file "/opt/sas/data/xxxx/xx/xxx/Folder1/Source/xxxx.csv" dlm='|' ;
do until(cc>ll);
input value ~ :$char32767. @;
if missing(value) then value ='""';
put value :$char32767. @;
end;
put;
run;


The problem comes when I put a route in the infile that is in "J:", I get this error:

"ERROR: Invalid open mode."

 

and this too:

ERROR: Some code points were not transcoded. SAS
ERROR: Some code points were not transcoded. SAS

ERROR: Some code points were not transcoded. SAS

But these I think is because of the encoding, even though I am saying that the encoding has to be utf-8. But I think the problem lies in the path and the invalid open error

 

Can someone shed some light on this for me? If you know another way to try to do what I'm doing with another method in SAS let me know, but I'm trying to automate the transformation of certain csvs in a flow and I need this step.

Thank you very much in advance, greetings!

3 REPLIES 3
Reeza
Super User

Are you certain that the second J folder location is accessible to the SAS server?

The first example that works but the path is unix and on the SAS server, whereas the second path looks like it's a Windows network path but you also state that the file was originally in the J network?

 


@Abelp9 wrote:

Hello everyone, I'm trying to automatically change the delimiter of a csv file that is in a certain path (in J:, the local server of my company) and leave it in the SAS server.

 

It turns out that when I run this code it works for me:

data _null_;
infile "/opt/sas/data/xxx/xx/xx/Folder1/xxxx.csv" dlm='|' dsd length=ll column=cc truncover ENCODING='utf-8';
file "/opt/sas/data/xxx/xxx/xxx/Folder1/Source/xxxx.csv" dlm='|' ;
do until(cc>ll);
input value ~ :$char32767. @;
if missing(value) then value ='""';
put value :$char32767. @;
end;
put;
run;

 

Since I take the csv file from a folder in J and put it in another folder in J like that, doesnt works:

data _null_;
infile "J:\xxxx\xxx\xxxxx\xxxxx.csv" dlm='|' dsd length=ll column=cc truncover ENCODING='utf-8';
file "/opt/sas/data/xxxx/xx/xxx/Folder1/Source/xxxx.csv" dlm='|' ;
do until(cc>ll);
input value ~ :$char32767. @;
if missing(value) then value ='""';
put value :$char32767. @;
end;
put;
run;


The problem comes when I put a route in the infile that is in "J:", I get this error:

"ERROR: Invalid open mode."

 

and this too:

ERROR: Some code points were not transcoded. SAS
ERROR: Some code points were not transcoded. SAS

ERROR: Some code points were not transcoded. SAS

But these I think is because of the encoding, even though I am saying that the encoding has to be utf-8. But I think the problem lies in the path and the invalid open error

 

Can someone shed some light on this for me? If you know another way to try to do what I'm doing with another method in SAS let me know, but I'm trying to automate the transformation of certain csvs in a flow and I need this step.

Thank you very much in advance, greetings!


 

ballardw
Super User

Show, from the log, the code and the error messages. When you separate the error from the code you make it harder to interpret. Also, copy the entire data step text with all messages, notes, warnings and errors from the log, on the forum open a text box using the </> and paste the result.

The main message windows here will reformat text which may move diagnostic characters often provided in SAS logs making them less useful.

 

Which part of that code do you think "changes the delimiter"? You specify the same delimiter with the DLM='|' on both the infile and file statements. So that part of your question is very confusing as to what you actually are attempting.

 

It might help to post a small 2 or 3 line example of the input file and what you expect from the result.

 

If you are running SAS in any sort of server environment then paths like your 'J:' drive are likely not available to the server and would create;

 

You specify an Encoding for the INFILE but your values in the data step may be transcoded to your SAS system setting for use. Which may not work for comparisons or calculations.

 

Tom
Super User Tom
Super User

Your other paths look like normal Unix paths.  Since they start with the root node (/) they are absolute paths.  But to Unix a path that starts with J will be a relative path.  And to unix the \ is an escape character that means treat the next character as a plain character even if it is normally not.  So you asked SAS to look for a file named J:xxxxxxxxxxxxxxxxx.csv in the current working directory.

 

If you want your SAS code to reference the J: drive then have your system admins mount that drive somewhere on your Unix filesystem and reference the file there.  So if the J:\xxxx folder is mounted /opt/j/xxxx/  then the path you will need to use in your SAS code to reference the file is:  /opt/j/xxxx/xxx/xxxxx/xxxxx.csv

 

Or upload the file from your PC to some place on the machine where SAS is running and reference it from there.

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
  • 3 replies
  • 363 views
  • 5 likes
  • 4 in conversation