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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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