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

Hello,

 

I am using a proc copy to copy a spde dataset from staging to dev (just the data structure).

 

Here's the code:

libname sauto spde 'path1';

libname sprop spde 'path2';

libname dauto spde 'path3';

libname dprop spde 'path4';

 

options obs=0;
proc copy in=sauto out=dauto;
select wc_auto_inforcesep2020 ;
run;

 

Is there a way  to add a new variable such as format newvar $2. to a spde dataset, maybe with proc copy????

Thanks in advance for your help

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

No, you can't make any structural changes with proc copy. For this, you need a data step, or COPY and then ALTER TABLE in SQL. My observation was that ALTER TABLE still needs to rewrite the whole dataset, so, performancewise, you will be better off by using a DATA step to copy a dataset to SPDE and add a variable on the way.

View solution in original post

4 REPLIES 4
LinusH
Tourmaline | Level 20

There is no real difference between managing SPDE and Base SAS data sets.

The sImple answer is no.

What you can do is do the PROC COPY, and then SQL ALTER TABLE.

The table will be recreated, but that's probbaly fine since it's just the structure, not a mssive amount of data.

Data never sleeps
Kurt_Bremser
Super User

@LinusH wrote:

 

The table will be recreated, but that's probbaly fine since it's just the structure, not a mssive amount of data.


It will rewrite the whole table; with SAS, any structural change requires this.

Given the relative performance of SPDE libraries (thanks to threading), this will be considerably faster than changing a V9 dataset.

I just ran a test with a larger dataset here; creating the dataset by copying from the V9 engine took 43 seconds, adding the column 15 seconds.

alepage
Barite | Level 11
Hello Mr. Bremser,
I am sorry but it is not clear for me. Did you find a way to add a new variable using proc copy or you have use a data datasetname1; set datasetname; format newvar $2.;run; If there is a way to do it with the proc copy, could you please provide me an example.

Best Regards,

Kurt_Bremser
Super User

No, you can't make any structural changes with proc copy. For this, you need a data step, or COPY and then ALTER TABLE in SQL. My observation was that ALTER TABLE still needs to rewrite the whole dataset, so, performancewise, you will be better off by using a DATA step to copy a dataset to SPDE and add a variable on the way.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 4 replies
  • 1085 views
  • 1 like
  • 3 in conversation