BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rselmon0
Calcite | Level 5

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 ;

 

1 ACCEPTED SOLUTION

Accepted Solutions
JediApprentice
Pyrite | Level 9

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;

View solution in original post

3 REPLIES 3
ballardw
Super User

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.

JediApprentice
Pyrite | Level 9

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;
rselmon0
Calcite | Level 5
Thank you so very much!

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!

SAS Enterprise Guide vs. SAS Studio

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.

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
  • 3 replies
  • 1103 views
  • 0 likes
  • 3 in conversation