Obsidian | Level 7

## Array

Write a SAS program that will:
• Create output data set work.ACT01 using sashelp.pricedata as input.
• Use an array to increase the values of the price1 through price17 variables by 10%.

How to solve this?

6 REPLIES 6
Diamond | Level 26

## Re: Array

We don't usually do your homework for you. However, if you give it a try and can't seem to get it to work, show us your code and we will be happy to help.

--
Paige Miller
Super User

## Re: Array

Here's a start. Fill it what you have attempted for the array and calculations.

```data work.ACT01;
set sashelp.pricedata;
run;```
Obsidian | Level 7

## Re: Array

This is what I tried. But I'm stuck on adding the value to original price after doing the percent.

data work.ACT01;
set sashelp.pricedata;
array Prices(12)price1--price12;
do i=1 to 12;
prices(i)=prices(i) * (10/100);
end;
run;
Super User

## Re: Array

One percent is 0.01 of the original value. 10 percent are 0.1 of the original value. To add 10 percent, you have to multiply the original value by 0.1, and add that to the original value.

``x = x + x * 0.1;``

or, simplified

``x = x * 1.1;``
Super User

## Re: Array

@POOJA_J wrote:

Write a SAS program that will:
• Create output data set work.ACT01 using sashelp.pricedata as input.
• Use an array to increase the values of the price1 through price17 variables by 10%.

How to solve this?

Here's a tutorial on using Arrays in SAS
https://stats.idre.ucla.edu/sas/seminars/sas-arrays/

See the example under "Computing new variables", though make sure you double check your answer.

Super User

## Re: Array

Discussion stats
• 6 replies
• 398 views
• 8 likes
• 5 in conversation