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

I'd like call datasets from specific library and change their names in work library. I'm not allowed to change the dataset names permanently because of shared property. I have 30 datasets and will execute the proc datasets in macro once my code works out outside the macro. What am I doing wrong?

 

LIBNAME m "......\work_data";

proc datasets lib=m;
change m.data2015_bf=data_2015; 
run;
quit 

Error log:

 

126 proc datasets lib=m;

127 change m.data2015_bf=data_2015;

----------------

22

201

ERROR 22-322: Expecting a name.

ERROR 201-322: The option is not recognized and will be ignored.

128 run;

NOTE: Enter RUN; to continue or QUIT; to end the procedure.

NOTE: Statements not processed because of errors noted above.

129 quit

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Do you know what I have never even heard of the change operation in proc datasets.  Me I would simply do, as you want to copy them to work and not change them in place - which is where your error happens (I imagine you don't have permission to change them):

data _null_;
  set sashelp.vtable (where=(libname="M"));
  call execute('data '||strip(memname)||'; set m.'||strip(memname)||'; run;');
run;

That will do a datastep to copy each one from M to work, you can also include your rename part there, so you want an underscore:

data _null_;
  set sashelp.vtable (where=(libname="M"));
  call execute('data '||substr(memname,1,4))||'_'||substr(memname,5)||'; set m.'||strip(memname)||'; run;');
run;

 

View solution in original post

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Do you know what I have never even heard of the change operation in proc datasets.  Me I would simply do, as you want to copy them to work and not change them in place - which is where your error happens (I imagine you don't have permission to change them):

data _null_;
  set sashelp.vtable (where=(libname="M"));
  call execute('data '||strip(memname)||'; set m.'||strip(memname)||'; run;');
run;

That will do a datastep to copy each one from M to work, you can also include your rename part there, so you want an underscore:

data _null_;
  set sashelp.vtable (where=(libname="M"));
  call execute('data '||substr(memname,1,4))||'_'||substr(memname,5)||'; set m.'||strip(memname)||'; run;');
run;

 

ballardw
Super User

If you are accessing the same data sets frequently you might be better off making your own permanent library and creating views that reference those data sets. Then when you access the view in your library it will read the "shared" data set and you have the latest data.

 

If you don't want to deal with having different observations at different times of the day then copying them to your work (or other library) could be in an autoexec.sas.

 

 

Cruise
Ammonite | Level 13

Figured out from RW9's insights and ballardw's suggestion:

I created a copy folder with all datasets and use that as my library=m. And defined generic library after proc and eliminating libname initials in front of the datasets after "change" line did the job. All I have to do now is to put it in the macro and do the same thing for the rest of the 30-40 datasets. Thanks a lot.

 

LIBNAME m "......\work_data";

 

proc datasets lib=m;

change oldname=newname;

run;

quit

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1209 views
  • 2 likes
  • 3 in conversation