I am using SAS Ondemand Academics, SAS Studio. For an assignment, codes were given and I have copied and pasted as well as iputted the codes manually. Error messgaes are available and I do not know how to correct the errors to yield the results. The attachment of the error message is for the code below.
DATA smo_cardio ; INPUT exposed $ disease $ patients ; DATALINES ; exposed disease 50 exposed none 50 not_exp disease 25 not_exp none 75 ; PROC FREQ DATA = smo_cardio ; TABLES exposed*disease / RELRISK RISKDIFF ; WEIGHT patients ; RUN ;
This is an additional code.
PROC CONTENTS DATA = sashelp.heart ; PROC FREQ DATA = sashelp.heart ; TABLES ageatdeath*deathcause / OUT = test1 ; PROC PRINT DATA = test1 ; PROC GPLOT DATA = test1 ; PLOT count*ageatdeath = deathcause ; WHERE deathcause in ("Cancer","Cerebral Vascular Disease", "Coronary Heart Disease") ; SYMBOL1 INTERPOL = JOIN ; DATA test2 ; SET sashelp.heart ; ageatdeath5 = ROUND(ageatdeath,5) ; PROC FREQ DATA = test2 ; TABLES ageatdeath5*deathcause / OUT= test3 ; PROC GPLOT DATA = test3 ; PLOT count*ageatdeath5 =deathcause ; WHERE deathcause IN ("Cancer","Cerebral Vascular Disease","Coronary Heart Disease") ; SYMBOL1 INTERPOL = JOIN ; RUN ;
You're also missing a bunch of run statements. Try copy and pasting this instead:
DATA smo_cardio;
INPUT exposed $ disease $ patients;
DATALINES;
exposed disease 50
exposed none 50
not_exp disease 25
not_exp none 75
;
RUN;
PROC FREQ DATA = smo_cardio;
TABLES exposed*disease / RELRISK RISKDIFF;
WEIGHT patients;
RUN;
PROC CONTENTS DATA = sashelp.heart;
RUN;
PROC FREQ DATA = sashelp.heart;
TABLES ageatdeath*deathcause / OUT = test1;
RUN;
PROC PRINT DATA = test1;
RUN;
PROC GPLOT DATA = test1;
PLOT count*ageatdeath = deathcause;
WHERE deathcause in("Cancer","Cerebral Vascular Disease","Coronary Heart Disease");
SYMBOL1 INTERPOL = JOIN;
RUN;
DATA test2;
SET sashelp.heart;
ageatdeath5 = ROUND(ageatdeath,5);
RUN;
PROC FREQ DATA = test2;
TABLES ageatdeath*deathcause / OUT = test3;
RUN;
PROC GPLOT DATA = test3;
PLOT count*ageatdeath5 = deathcause;
WHERE deathcause in("Cancer","Cerebral Vascular Disease","Coronary Heart Disease");
SYMBOL1 INTERPOL = JOIN;
RUN;
Please post attachments as TEXT files not Microsoft office documents or spreadsheets due to issues around security. Many users here will not open them, or their security settings will not allow them to open these files.
I wonder if you are using code that was copied from somewhere and pasted into the editor. Some sources end up embedding characters that are not visible but are detected by the code parser. If you did copy and paste, then delete the text and type it from scratch.
Also with DATALINES it is a good practice to left justify the data.
You're also missing a bunch of run statements. Try copy and pasting this instead:
DATA smo_cardio;
INPUT exposed $ disease $ patients;
DATALINES;
exposed disease 50
exposed none 50
not_exp disease 25
not_exp none 75
;
RUN;
PROC FREQ DATA = smo_cardio;
TABLES exposed*disease / RELRISK RISKDIFF;
WEIGHT patients;
RUN;
PROC CONTENTS DATA = sashelp.heart;
RUN;
PROC FREQ DATA = sashelp.heart;
TABLES ageatdeath*deathcause / OUT = test1;
RUN;
PROC PRINT DATA = test1;
RUN;
PROC GPLOT DATA = test1;
PLOT count*ageatdeath = deathcause;
WHERE deathcause in("Cancer","Cerebral Vascular Disease","Coronary Heart Disease");
SYMBOL1 INTERPOL = JOIN;
RUN;
DATA test2;
SET sashelp.heart;
ageatdeath5 = ROUND(ageatdeath,5);
RUN;
PROC FREQ DATA = test2;
TABLES ageatdeath*deathcause / OUT = test3;
RUN;
PROC GPLOT DATA = test3;
PLOT count*ageatdeath5 = deathcause;
WHERE deathcause in("Cancer","Cerebral Vascular Disease","Coronary Heart Disease");
SYMBOL1 INTERPOL = JOIN;
RUN;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.