09-20-2017 11:41 AM
I'm a newbie with SAS archiving of data. I would like to know how can I delete older datas w/o affecting indexes and account/party keys.
I need to delete data w/ year 2010 and below. The account/party resets to 0,1,2,3,4 so on so forth where in it should start to different count. I hope I make sense.
09-20-2017 09:19 PM
09-21-2017 02:09 AM
There is no auto increment field in SAS.
So you are probably using Oracle data or similar.
If you don't want to value to change, you have to turn off in auto-increment.
You can't ask for the field to be populated automatically and for the field not to change.
09-21-2017 06:45 AM - edited 09-21-2017 06:49 AM
That's certainly not a SAS table unless you're telling us only a very scalled down and distorted part of the story. If you're interfacing with a database then what's the database?
If it's Oracle then there would be options to implement an autoincrement field which generates a key for you which doesn't change (i.e. using a sequencer object in an insert trigger; the newer versions of Oracle also have a specific new field type for such a requirement).
...but as @ChrisNZ already hints: That's something you need to solve on the database side.
09-21-2017 11:50 AM - edited 09-21-2017 11:51 AM
Looks like this but again, the party_key count will reset to 0,1,2,3 so on so forth. I want to retain the party_key index.
create table tmp as
select * from core.transaction_table where
month_key <= 201201
09-21-2017 01:24 PM
What are you talking about? The code you posted creates a new dataset named "tmp", there is no code creating an index.
The concept "index" is described here.
09-21-2017 03:48 PM
Can you explain what you are talking about? SAS will not change any data values if you delete observations.
data have ; length ACCOUNT_PARTY 8 NAME $20 DATE 8; input ACCOUNT_PARTY NAME DATE ; cards; 1 ALPHA 2017 2 BETA 2016 3 CHARLIE 2018 4 DELTA 2015 5 FOXTROT 2016 ; proc sort data=have ; by date ; run; proc print data=have ; run; proc print data=have ; where date > 2016 ; run;
09-28-2017 05:16 AM
After deleting rows, how am i going to compress the dataset? It is still 17GB albeit more than 500k rows were deleted.
I've tried this,
create table tmp
***then delete rows****
It worked. However, it is in work library. I want to do it directly to the dataset where I am going to delete rows/data.
09-28-2017 05:09 PM
"It worked. However, it is in work library. I want to do it directly to the dataset where I am going to delete rows/data."
If you want it in a permanent library then simply create the new table in a permanent library: create table <libref>.<table name> as ...
"I want to do it directly to the dataset "
A Proc SQL/DELETE will only logically delete the rows. If you want the data set size reduced then you need to re-create the table (i.e. using your current SQL CREATE statement).