Obsidian | Level 7

## How to make a table and corresponding line graph?

(Sorry if I post this to the wrong location)

Hello,

I just started using SAS Univ. Edition(latest version) and I have several questions.

I'm trying to create a table and corresponding line chart, which I found in the previous research paper of my research field.

(The following is the replicate of the original table and graph by myself. Numbers or names etc are all made-up. What I want to make is this type of table and chart.)

This table and charts are made with SAS (it's what the paragraph above states.), so there should be any way to create this.

However, since I'm not getting used to this yet, I couldn't find any at this stage.

Could any of you have a solution for this?

Any help will be welcome!

If you have any question regarding this photo, just reply to my post and I'll answer it.

1 ACCEPTED SOLUTION

Accepted Solutions
Rhodochrosite | Level 12

## Re: How to make a table and corresponding line graph?

Look at procs freq, tabulate, means, report, and sgplot to get started.

10 REPLIES 10
Rhodochrosite | Level 12

## Re: How to make a table and corresponding line graph?

Look at procs freq, tabulate, means, report, and sgplot to get started.

Obsidian | Level 7

## Re: How to make a table and corresponding line graph?

I just want to confirm whether I'm understanding what you've adviced me correctly or not.

proc freq-???

proc tabulate-for making a table

proc means-for getting the average

proc report-for printing the data

proc sgplot-for drawing graph connecting average points?(using vline?)

I wonder what proc freq for... could you explain what it is for(and anything if I'm misunderstanding)?

Tourmaline | Level 20

## Re: How to make a table and corresponding line graph?

Replicate the data in your photo with made-up values and post it along with a drawing/sketch of what you want you output table and graph to look like. That way, we are able to give you a usable code answer, you can apply the code to your actual problem and you don't have to worry about copyright issues 🙂

Obsidian | Level 7

## Re: How to make a table and corresponding line graph?

OK, I'll make the made-up table and graph from now, and add it to the original post as attachments.

Obsidian | Level 7

## Re: How to make a table and corresponding line graph?

Just to notify I changed the inserted photo to the replicate made-up one!

Tourmaline | Level 20

## Re: How to make a table and corresponding line graph?

You are welcome. If your data looks like what you have posted, this might get you started on the graph you want to create

``````data have;
input Fruits\$ Tom Michael Kelly Emi;
datalines;
Apple 3 1 2 3
Pear 1 3 0 2
Banana 1.5 2 1 2.5
;

proc sort data=have;
by Fruits;
run;

proc transpose data=have out=have_long(rename=(_NAME_=Name COL1=eat));
by Fruits;
run;

proc sgplot data=have_long noautolegend;
title "Fruits";
styleattrs datasymbols=(CircleFilled SquareFilled TriangleFilled);
series x=Name y=eat / group=Fruits markers;
xaxis display=(nolabel) grid;
yaxis values=(0 to 3 by 1) grid label="Frequency of Eating";
run;
title;``````

If you want to further edit the visual aspects of the plot, consult the PROC SGPLOT Documentation

Obsidian | Level 7

## Re: How to make a table and corresponding line graph?

Thank you very much for your help!!

I copied the code and paste it into the program area, and it perfectly worked!!

it seems there are lots of stuff which I can customize.

I'll have a look at the page and see what I need to do to make it closer to what I imagined it to be.

(like changing ● in the graph to ■ and ◆, changing lines, adding explanatory notes etc)

Thank you again for helping me a lot!!

Tourmaline | Level 20

Super User

## Re: How to make a table and corresponding line graph?

First of all, start out by creating a dataset. Creating test data works in the same way that we prefer for posting example data here:

``````data have;
input name \$ fruit \$ eating;
cards;
Tom Apple 3
Tom Pear 1
Tom Banana 1.5
Michael Apple 1
;
run;``````

Expand the step so it creates all your data. Understanding this simple data step is your first learning step.

Next, tinker around with applying the procedures named by the others to your dataset and see what happens.

Obsidian | Level 7

OK, I will.