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
Onyx | Level 15

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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