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

Hi,

I am using SQL to build my datasets and get "warnings" if the name of the modified new dataset is the same as the original dataset.

 

For example:

Dataset Old =

ColA, ColB

 

Dataset New =

ColA, ColB, ColC

(one attribute added)

 

When I call the new dataset the same name as the name of the old dataset, I get a "warning" in the error log.

 

What is a good and simple technique to build my dataset out and so that

1.  I end up with only one dataset and

2.  The result has the name of the Original dataset (even if I have modified the dataset 5 or 6 times) and

2.  I can eliminate all of the warnings?

 

A simple example would help.

(when I research, I find much on renaming attributes but not much on datasets)

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

However NOT recommended, You can opt to data step to get rid of the warning.

data old;
set old;
run;

But if anything goes wrong (e.g. power outage), then you may lost your original data.

 

@Reeza's suggestion is dead on. Name it differently for every change you make, then using Proc dataset to clean the house, doing that guarantee you easy trouble-shoot and better approach of programming.

View solution in original post

6 REPLIES 6
Kody_devl
Quartz | Level 8

I am using SQL to build my datasets and get "warnings" if the name of the modified new dataset is the same as the original dataset.

 

For example:

Dataset Old =

ColA, ColB

 

Dataset New =

ColA, ColB, ColC

(one attribute added)

 

When I call the new dataset the same name as the name of the old dataset, I get a "warning" in the error log.

 

What is a good and simple technique to build my dataset out and so that

1.  I end up with only one dataset and

2.  The result has the name of the Original dataset (even if I have modified the dataset 5 or 6 times) and

2.  I can eliminate all of the warnings?

 

A simple example would help.

(when I research, I find much on renaming attributes but not much on datasets)

 

 

 

 

 

 

Reeza
Super User

If your using multiple steps, use names that are unique to each step and then make a final dataset. You can use proc datasets to both remove extra data sets and to rename the final dataset if you'd like. 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

The warning you get is telling you that writing to the same dataset that you read from will mean you cannot roll the changes back.  Its an SQL implementation thing.  You can put:

proc sql undopolicy=none;

...

 

That will remove the wraning.  However you may be better off just using datastep language - without seeing your process I can't really advise, but you can merge various datasets and do logic in one step:

data want;
  set old:;
  colc="Hello World";
run;

This would bring in all datasets in work with the prefix old, and create a new variable in the output want dataset.

Haikuo
Onyx | Level 15

However NOT recommended, You can opt to data step to get rid of the warning.

data old;
set old;
run;

But if anything goes wrong (e.g. power outage), then you may lost your original data.

 

@Reeza's suggestion is dead on. Name it differently for every change you make, then using Proc dataset to clean the house, doing that guarantee you easy trouble-shoot and better approach of programming.

Kody_devl
Quartz | Level 8

This Works couple with dropping the Old Dataset.

 

Thank you

 

 

MMMIIIIKKKKEEEE
Obsidian | Level 7

Cody_Devl,

 

I see that you got your answer and I'll bet that you have already implemented it.  Great!

 

I have another idea that will address requirements #2 and #3 that may come in handy some day.  Consider creating Generation Data Groups for the data sets you want to modify.  For example:

 

   proc datasetslibrary=sgflib nolist;

  modify ColA(genmax=10);

  modify ColB(genmax=10);

   run;

    quit;

 

Then, when you modify ColA or ColB, SAS will save the old copies as ColA#001, ColB#001, respectively and keep the modified versions.

 

Don't take my word for it; check it out!

 

 

Best of luck in all your SAS endeavors!

----MMMMIIIIKKKKEEEE
(aka Michael A. Raithel)
Amazon Author's Page: http://www.amazon.com/Michael-A.-Raithel/e/B001K8GG90/ref=ntt_dp_epwbk_0

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!

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
  • 6 replies
  • 1206 views
  • 3 likes
  • 5 in conversation