@Tom thanks so much! I tried your solution and it did work out in the programs. The column TERMID is a character variable. I use (input(termid, best6.) -503) to calculate the reference term that I want, which is 201505 (202008-503=201505). I put your quote statement in the second macro, and it gave me a list of terms with double quotes like "201505" ''201508"... then I execute the marco in later programs and I have 15 term information. %GLOBAL TERMCODE;
PROC SQL;
SELECT quote(strip(put(input(termid, 32.),6.)))
INTO :TERMCODE separated by ", "
FROM SID.SID_Termid WHERE TERMID IN (select a.termid from SID.SID_Termid a where a.latestbenchmark = 'E' AND a.termid ge Put((&Term_From), 6.));
QUIT; this is how i execute the macro Proc sql;
Create Table Crs_records AS
SELECT count(*) AS Num_rec
FROM SID.SID_COURSES_TAKEN CRS
WHERE fee_class_kind ^= 'P'
AND termid in (&TERMCODE);
Create table crs_rec_by_terms_bench AS
SELECT termid, bench, count(distinct UID) AS Num_rec
FROM SID.SID_COURSES_TAKEN CRS
WHERE fee_class_kind ^= 'P'
AND termid in (&TERMCODE)
GROUP BY termid, bench
ORDER BY termid Desc, bench;
quit;
... View more