turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- Macro + plotting + do question.

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-06-2014 06:02 PM

Hello, I am having trouble to generate code for an assignment.

Here is the Questions:

**Write macro to print and plot the exponential function of a given “base” starting in the range “start” – to – “end” calculated by increment “incr”.**

**Add the title indicating what function you are plotting, in what range and ny what increment. **

** **

**Run your macro as:**

%** exp_plot**(

%** exp_plot**(-

%** exp_plot**(-

**Here is the code i have so far:**

%macro exp_plot(base,start,end,incr);

data plot1;

%do i=&start %to &end %by &incr;

result=&base**&i;

output;

%end;

run;

proc plot data=plot1;

plot result;

run;

%mend exp_plot;

%exp_plot(.5, -10, 10,.5)

%exp_plot(-.5, -10, 10,.5)

%exp_plot(-.5, -10, 10,.5)

**Can someone please point me in the right direction?**

Accepted Solutions

Solution

12-06-2014
07:15 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to a_gomesd

12-06-2014 07:15 PM

OK. Two hints.

1. you have to increment %do loops with integers

2. I think proc plot will require that you plot two variables

All Replies

Solution

12-06-2014
07:15 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to a_gomesd

12-06-2014 07:15 PM

OK. Two hints.

1. you have to increment %do loops with integers

2. I think proc plot will require that you plot two variables

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to art297

12-06-2014 09:45 PM

Thank you Arthur, I managed to figure it out thanks to your hints. If I understand correctly, you cannot use non-integer values to increment in a %do loop therefore the problem is in the question as it is the question that requests us to use the value of 0.5 for incremental.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to a_gomesd

12-06-2014 10:40 PM

No.

Why are you using %do in a data step, use a regular do loop instead.

Is there a proc plot?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to a_gomesd

12-06-2014 11:41 PM