DATA Step, Macro, Functions and more

Can a SAS Dataset be updated in a DATA STEP? Not copied

Reply
Contributor
Posts: 55

Can a SAS Dataset be updated in a DATA STEP? Not copied

I need to change a value of a field on a giant SAS dataset based on an array match. Normally this would just be making a copy of the file. Unfortunately this file will have millions of records with a record length of 5000 bytes. It would be much more efficient to NOT copy the data but update the column in place. Note that no columns are indexed on this dataset so there are no problems in changing column values.

I could do this in PROC SQL but it would slower that just using a DATA step with an array lookup. That is, if a datastep can update a dataset in place without copying it.

Does anybody know how to do this in a DATA step?
Respected Advisor
Posts: 3,777

Re: Can a SAS Dataset be updated in a DATA STEP? Not copied

I think the data step MODIFY statement is what you are looking.
Contributor
Posts: 55

Re: Can a SAS Dataset be updated in a DATA STEP? Not copied

Thanks. The modify did not show up easily while searching the online documentation.

The following worked.

data work.master;
ARRAY id(&max);
%do x=1 %to &max %by 1;
id(&x)=&&id&x;
putlog 'id = ' id(&x);
%end;
loop:
modify work.master end=eoj;
id=newid(id);
replace;
if eoj then stop;
goto loop;
run;
Ask a Question
Discussion stats
  • 2 replies
  • 105 views
  • 0 likes
  • 2 in conversation