Hi ,
I am trying to use has as a look up table to join two tables. My issues is i will get data from the source table only once in four days. For other days the table will have zero records. Because of this reason I am not able use this code since my macro count variables wont be created for data set with zero records since the logic wont enter the do until loop. Can u help me with a logic so that i can join the tables if the data exists or create a macro variable with zero as count if the source key dataset is empty
data work.sasgrid_extract(drop= rc tot_cnt);
set work.source_key_extract ;
declare hash stac (dataset: 'work.source_key_extract');
stac.definekey('acct');
stac.definedone();
do until(eof);
set vp.account_table (keep = acct
amount
type
code
flag
date
) end=eof ;
rc = stac.find();
if rc eq 0 then do;
sas_acct = acct;
tot_cnt+1;
output;
end;
call symputx("sas_stac_cnt",tot_cnt);
end;
stop;
run;
Just code your step so that it does try to read past the end of the input dataset.
It looks like you are not really using that first SET statement to read the data (that is being done later) so make it impossible to execute.
if 0 then set work.source_key_extract ;
and then SAS will not try to read past the end when it is empty.
Just code your step so that it does try to read past the end of the input dataset.
It looks like you are not really using that first SET statement to read the data (that is being done later) so make it impossible to execute.
if 0 then set work.source_key_extract ;
and then SAS will not try to read past the end when it is empty.
create a macro variable with zero as count if the source key dataset is empty
Just add
call symput('sas_stac_cnt','0');
before the SET statement.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.