DATA Step, Macro, Functions and more

Proc Export - Error: String is duplicated

Reply
Contributor
Posts: 28

Proc Export - Error: String is duplicated

Hi

 

I have an export step at the end of my code which exports to a excel document on a specific sheet.

 

Within that excel doc there is a second sheet which links to this data.

 

When I initially run (and on most subsequent runs) it all works fine however sometimes when I run I get an error message saying "Error: String is duplicated" plus some symbols in brackets.

 

If I get this error message it seems to still export data but also corrupts the excel file. I can go into the excel file but column names have moved, formats changed etc which shouldn't happen. 

 

Does anyone know what this error message means and how to fix the issue. Odd how it only happens sometimes (though seems to happen more often if I run the full script rather than bit by bit). Code is below. Currently I am only testing it for one client but eventually this will be rolled out to run across multiple clients. I use SAS Studio but don't think this is important for this issue.

 

 

%macro Export (i,j);
data &j._output;
set summary ;
where Client_name = "&i.";
run;

 

PROC EXPORT DATA= WORK.&j._output
OUTFILE= "\\<file location>\&i..xlsx"
DBMS=xlsx
REPLACE;
SHEET = 'Raw';
RUN;

%mend Export;


%export(client 1,client 1);

Super User
Posts: 17,963

Re: Proc Export - Error: String is duplicated

This is an Excel error? I haven't seen that error but I noticed that the SHEETNAME option is fixed. Im assuming you're writing to a template? 

 

It may be possible that there's something in a specific report that's causing the issue. 

 

Rather than create the subset you can place the WHERE in your PROC EXPORT. 

Contributor
Posts: 28

Re: Proc Export - Error: String is duplicated

Hi Reeza

 

No it isn't an excel error. This error appears in the SAS log but for some reason doesn't always occur. It's not an error I have seen (or anyone in my office I have asked has). It's an odd error as it doesn't seem to relate to the statement in anyway. Usually SAS errors have some sort of clue in.

 

This makes me wonder if it's something to do with space because it is a lengthy script although the actual export is only 12 rows for this particular client.

 

https://communities.sas.com/t5/General-SAS-Programming/PROC-EXPORT-lt-lt-ERROR-string-is-duplicated-...

 

is another post with the same issue however has no resolution

Super User
Posts: 17,963

Re: Proc Export - Error: String is duplicated

I would contact tech support. If needed the developers may be able to say how that error is generated. 

Super User
Posts: 17,963

Re: Proc Export - Error: String is duplicated

Do you actually have spaces in your i/j variables? 

Contributor
Posts: 28

Re: Proc Export - Error: String is duplicated

In this case no. i and j are both 1 word. I have called it client 1 up top instead of the actual client. There are also no odd characters within the client name. Just letters.

 

When I add additional clients, some will have spaces but this isn't an issue in this instance.

Ask a Question
Discussion stats
  • 5 replies
  • 292 views
  • 0 likes
  • 2 in conversation