Set data according to one variable in a table

Posts: 24

Set data according to one variable in a table

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);

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.




Trusted Advisor
Posts: 1,837

Re: Set data according to one variable in a table

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. 

Posts: 24

Re: Set data according to one variable in a table

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;

where loca2 is link table for smybol and cusip. 

Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation