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;

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
  • 2 replies
  • 627 views
  • 0 likes
  • 2 in conversation