Hi all, I am very new to SAS . Looking to see the number of patients that have taken a medication only once for between 1-5 days and for what treatment and compare it with the 1995/96 data. The script below is for 2015/16 data. %_eg_conditional_dropds(WORK."%STR(1516)"n); PROC SQL; CREATE TABLE WORK.'1516'n AS SELECT t1.FYEAR, t1.DOB, t1.MEDICATION, t1.TREATMENT t1.SEX, t1.ID, t1.STARTDATE, t1.ENDDATE FROM DRUGDATA.YEAR1516 t1 where MEDICATION=1; QUIT; PROC SQL; create table MED1516 as select t1.DOB, t1.MEDICATION, t1.TREATMENT t1.SEX, t1.ID, t1.STARTDATE, t1.ENDDATE, ENDDATE-STARTDATE AS amtdaysonmed FROM DRUGDATA.YEAR1516 t1 where MEDICATION=1; QUIT; I have three questions. 1. Is there a way to combine the two steps and still create MED1516?. 2. When I tried to add amtdaysonmed <6 (FROM DRUGDATA.YEAR1516 t1 where MEDICATION=1 and amtdaysonmed <6) it said it couldn't find amtdaysonmed. ERROR: The following columns were not found in the contributing tables: amtdaysonmed. But I can see amtdaysonmed when I checked on output Data.I have tried to do another PROC SQL and add amtdaysonmed but it doesn't work either 3. Is there a way to sort the data by the treatments the drugs are used for? Thank you for your time
... View more