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. 

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