^^
The first two datasteps kind of do what I'm after, but it removes the cls dataset, which I want to retain.
The third datastep was there for me to check that the index was still there after the change (and it was).
The final datastep is my current solution, but I don't really want to essentially recreate the dataset.
I'm running SAS 9.3 using Enterprise Guide 5.1 (5.100.0.12269) Hot fix 7 (32-bit)
Thanks.
Hi JohnT
You can not copy a SAS Data Set within the same library. However you can use other statements from Proc DATASETS to achieve the same. Have a look at the code below. It will delete an existing CLS2 data set. It then uses the APPEND statement, if the base table is not found, then append will make a copy of the data table and preserve index etc.
So . . . you want to keep the original dataset (CLS), and you don't need the final dataset (CLS3)?
Sorry I should have been more specific. Ignore the last two steps, I want CLS and CLS2, they were just for checking and demonstrating my current solution.
data cls (index = (name) );
set sashelp.class;
run;
proc datasets library = work;
change cls = cls2; run;
quit;
Hi JohnT
You can not copy a SAS Data Set within the same library. However you can use other statements from Proc DATASETS to achieve the same. Have a look at the code below. It will delete an existing CLS2 data set. It then uses the APPEND statement, if the base table is not found, then append will make a copy of the data table and preserve index etc.
Thanks Bruno, that solution works for me.
When I run it using my original solution compared to this one, the times are roughly the same, which is good. And the fact that the indexes are maintained is exactly what I was after.
Thanks again.
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.
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.