BookmarkSubscribeRSS Feed
Sasadomo
Calcite | Level 5

Say I have a table containing date variable and I want to recursively referring to taq libraries such as:

data zzz;
	set taqms.&type._&yyyymmdd;
	if ('9:35:00't) <= time_m <=('14:35:00't);
run;

where &type=ctm and &yyyymmdd is the date variable converted in to the form "yyyymmdd"  inside a macro.

 

But the %let command do not work well with date type variable and I am not able to assign the specific row observation to the &yyyymmdd variable.

 

For example, the date table:WeChat Image_20180408055009.png

And I want to recursively referring to taq libraries according to the date values above.

 

 

 

2 REPLIES 2
Shmuel
Garnet | Level 18

SAS date is a numeric variable containing number of days since 01JAN1960.

In order to assign the date in a format of yyyymmdd into a macro variable yyyyyo need to reformat it.

 

In the table you have a lot of different dates. Which of them you want to assign to the macro variable?

and how did you try to do it?

 

a singlae date can be assigned to a macro variable, in a sas datastep, using
     call symput('macro_var', put(date_var, yymmdd8.);

 

Better post your full code in oredr to get more accurate answer. 

Sasadomo
Calcite | Level 5

Thank you for your response. I would like to assign every date (each at the time, I have a do loop in the macro function) to the macro and perform something like this:

proc sql; create table temp as 
select a.*, b.cusip, b.secd
from taqms.&type._&day a, loca2 b
where a.sym_root=b.symbol and (b.sect-&window) <= a.time_m <= (b.sect+&window)
order by b.symbol;
quit;

where loca2 is link table for smybol and cusip. 

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