SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
anweinbe
Quartz | Level 8

Hi All,

 

Is it possible to create a standard deviation across columns?

 

I had to calculate the Return on Assets for every firm-year in my table along with 4 years of lags. I then need to take the standard deviation of each of the 5 years worth of ROA's. The problem is they are all in columns next to each other. I was hoping to create a new column that showed the SD of the preceding 5 columns.

 

My data looks like this:

 

I need to figure out the SD for Microsoft 2018 using the 5 numbers next to it!

 

Microsoft - 2018 - 3.75 - 3.56 - 3.43 - 4.52 - 1.25

Microsoft - 2017 - 3.56 - 3.43 - 4.52 - 1.25 - 2.45

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Use the STD function. 

http://support.sas.com/documentation/cdl//en/lefunctionsref/69762/HTML/default/viewer.htm#p1fani7wj5...

 


@anweinbe wrote:

Hi All,

 

Is it possible to create a standard deviation across columns?

 

I had to calculate the Return on Assets for every firm-year in my table along with 4 years of lags. I then need to take the standard deviation of each of the 5 years worth of ROA's. The problem is they are all in columns next to each other. I was hoping to create a new column that showed the SD of the preceding 5 columns.

 

My data looks like this:

 

I need to figure out the SD for Microsoft 2018 using the 5 numbers next to it!

 

Microsoft - 2018 - 3.75 - 3.56 - 3.43 - 4.52 - 1.25

Microsoft - 2017 - 3.56 - 3.43 - 4.52 - 1.25 - 2.45

 

Thanks!


 

View solution in original post

2 REPLIES 2
Reeza
Super User

Use the STD function. 

http://support.sas.com/documentation/cdl//en/lefunctionsref/69762/HTML/default/viewer.htm#p1fani7wj5...

 


@anweinbe wrote:

Hi All,

 

Is it possible to create a standard deviation across columns?

 

I had to calculate the Return on Assets for every firm-year in my table along with 4 years of lags. I then need to take the standard deviation of each of the 5 years worth of ROA's. The problem is they are all in columns next to each other. I was hoping to create a new column that showed the SD of the preceding 5 columns.

 

My data looks like this:

 

I need to figure out the SD for Microsoft 2018 using the 5 numbers next to it!

 

Microsoft - 2018 - 3.75 - 3.56 - 3.43 - 4.52 - 1.25

Microsoft - 2017 - 3.56 - 3.43 - 4.52 - 1.25 - 2.45

 

Thanks!


 

anweinbe
Quartz | Level 8

Ugh I can't believe what I did... I tried that but I put the STD() in the wrong place. I put it before each of the variables not thinking!

 

Thank you!!!

 

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 2 replies
  • 2560 views
  • 1 like
  • 2 in conversation