BookmarkSubscribeRSS Feed
Calvarez282
Calcite | Level 5

Hi all, 

 

I need help ASAP!

 

I am trying to create an "Mean (SD)" variable using a separate mean and SD variables, how can I do this? I have tried many things, but it is hard to add parenthesis and still have SAS read the variable names.

 

Thank you!

4 REPLIES 4
novinosrin
Tourmaline | Level 20

Looks like this is your first post. So welcome to the SAS forum. Sure, you will get help but you need to provide more details. A sample of your dataset, a sample of your requirement(output) and a logic. 

 

I wish I could show you a link that explains how to post a comprehensive question that is often shared by @Reeza /@Kurt_Bremser , but  I feel bad that I don't have it. Sorry

Reeza
Super User

Please post what you’ve tried so far. I would expect you to first summarize the data via PROC MEANS and then combine it using a data step (CATT) and then displaying via PROC PRINT. 

 

There is a paper called Creating Complex Reports from Cynthia Zender that has examples with code and definitely several on here. 

 


@Calvarez282 wrote:

Hi all, 

 

I need help ASAP!

 

I am trying to create an "Mean (SD)" variable using a separate mean and SD variables, how can I do this? I have tried many things, but it is hard to add parenthesis and still have SAS read the variable names.

 

Thank you!


 

Kurt_Bremser
Super User

@Calvarez282 wrote:

Hi all, 

 

I need help ASAP!

 

I am trying to create an "Mean (SD)" variable using a separate mean and SD variables, how can I do this? I have tried many things, but it is hard to add parenthesis and still have SAS read the variable names.

 

Thank you!


Short answer: don't. Use a valid SAS name (like mean_sd), consisting of letters, digits and underlines (and must not start with a digit), and put fancy names/descriptions in the label where they belong.

 

For detailed help how to calculate values etc, post the code you tried, example data (see my footnotes for how to do this), and the expected output/result.

s_lassen
Meteorite | Level 14

If you want to name your variables in non-standard ways, you will have to quote the names like this:

'Mean (SD)'n=<whatever expression you use to calculate it>;

 

Also, you will have to set 

option validvarname=ANY;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 4 replies
  • 461 views
  • 0 likes
  • 5 in conversation