BookmarkSubscribeRSS Feed
POOJA_J
Obsidian | Level 7

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
PaigeMiller
Diamond | Level 26

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
ballardw
Super User

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

 

data work.ACT01;
   set sashelp.pricedata;
run;
POOJA_J
Obsidian | Level 7
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;
Kurt_Bremser
Super User

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;
Reeza
Super User

@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.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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