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.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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