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

Is there a way to check (programmatically) whether a dataset was really copied using proc datasets; copy?

For example, in a program I use proc datasets; copy to copy a dataset, then I need to do some actions with this dataset. But before I do something with this dataset I want to check whether it was really copied (copying was not terminated by a poor connection or but some other reasons). How can I do it in my program?

Thanks for any help!

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Ok. How about this. Run Proc Datasets and check the SysCC macro variable for success.

 

proc datasets nolist;
   copy in = sashelp out = work memtype = data;
   select class;
run;quit;

%put &=syscc.;

proc datasets nolist;
   copy in = abc out = work memtype = data;
   select class;
run;quit;

%put &=syscc.;

View solution in original post

8 REPLIES 8
PeterClemmensen
Tourmaline | Level 20

I don't think Proc Datasets offers that.. Would it be enough to check if the copied dataset exist?

pavelr
Obsidian | Level 7

Thanks for your reply. To check if the copied dataset exist is not really enough, because it already exists there, but I need to copy (refresh/replace) this dataset periodically and to know whether proc datasets; copy failed or not. To delete this dataset before copying a new version of it is not an option either.

PeterClemmensen
Tourmaline | Level 20

Ok. How about this. Run Proc Datasets and check the SysCC macro variable for success.

 

proc datasets nolist;
   copy in = sashelp out = work memtype = data;
   select class;
run;quit;

%put &=syscc.;

proc datasets nolist;
   copy in = abc out = work memtype = data;
   select class;
run;quit;

%put &=syscc.;
pavelr
Obsidian | Level 7

This should work. I will try it.

Thank you very much!

pavelr
Obsidian | Level 7

Well, it doesn't fully solve the problem, because if some other step before proc datasets fails then syscc is set to an error number, so when proc datasets executes afterwards and doesn't fail - the syscc is not reset to 0.

Shmuel
Garnet | Level 18

If you get &syscc > 0 then copy failed. (&syscc=4 is a warning - should bechecked).

You can either abort this session and rerun the copy later in a new session or

you can reset it by:  %let syscc=0;  and continue with other steps.

In last case you need a warning message to show which file was not copied.

 

 

yabwon
Amethyst | Level 16

You could try FINFO() function to get modification date, see the doc for the details:

https://documentation.sas.com/?cdcId=vdmmlcdc&cdcVersion=1.0&docsetId=lefunctionsref&docsetTarget=p0...

 

Here is example from doc. which may help:

data info;
   length infoname infoval $60;
   drop rc fid infonum i close;
   rc=filename('abc', 'physical-filename');
   fid=fopen('abc');
   infonum=foptnum(fid);
   do i=1 to infonum;
      infoname=foptname(fid, i);
      infoval=finfo(fid, infoname);
      output;
   end;
   close=fclose(fid);
run;

all the best

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



pavelr
Obsidian | Level 7

Thank you, Bart! This seems to be a good solution too. Need to look into it.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 2144 views
  • 3 likes
  • 4 in conversation