BookmarkSubscribeRSS Feed
JMarkW
Fluorite | Level 6
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?
2 REPLIES 2
data_null__
Jade | Level 19
I think the data step MODIFY statement is what you are looking.
JMarkW
Fluorite | Level 6
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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1159 views
  • 0 likes
  • 2 in conversation