Can somebody help me to convert this code to Data Step or Proc SQL?
SAS code:
data cd;
set ab (rename=(x_ID=ID x_num=num x_year=year));
history_path = 0;
if _n_ = 1 then do;
length x_ID $9 x_num $3 x_year $4;
declare hash vertices(dataset: 'work.ab');
rc = vertices.definekey('x_ID', 'x_num', 'x_year');
rc = vertices.definedata('history');
rc = vertices.definedone();
call missing(x_ID, x_num, x_year, history);
length last_ID $9 last_num $3;
declare hash edges(dataset: 'work.ac', multidata: 'yes');
rc = edges.definekey('x_ID', 'x_num', 'x_year');
rc = edges.definedata('last_ID', 'last_num');
rc = edges.definedone();
call missing(last_ID, last_num);
end;
run;
Was this program working and now it isn't? If so have you tried increasing SAS's MEMSIZE option to provide more memory?
That data step does not appear to be using the HASH objects at all. Why not just remove that part of the code?
data cd;
set ab (rename=(x_ID=ID x_num=num x_year=year));
history_path = 0;
run;
What do you mean by "convert this code to Data Step" if it's already a DATA step?
As far as conversion to SQL goes, what's the purpose of the program? The only thing it currently does is load two data sets into two hash tables at _N_=1 and read the data from AB without processing the data in any way.
Kind regards
Paul D.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.