turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- generating standard deviation from PROC FREQ out p...

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-23-2018 06:11 PM

I have data for Survival collected from 4 plots in 4 blocks (n=16, N=4) marked as Y or N, so i used Proc FREQ via:

PROC FREQ data=TreesSAS;

by Species Measurement Fert Nfix;

TABLES Survival;

RUN;

and it generated a tables for each tree species, by measurement (Date) and treatment (Fert and Nfix), withe accompanying frequency, percent, cum. freq. and cum. perc.

Since Y and N are not numbers, they can't be analyzed for variance, but i would like to generate a standard deviation value for this data.

I tried using output out=Survival and then using the Proc Means statement with data=Survival, but the error message says that Survival does not exist.

How can i generate a Standard Deviation value for Survival in my data set?

%web_drop_table(WORK.IMPORT);

FILENAME FILEREF '/folders/myfolders/TreesSAS.xlsx';

PROC IMPORT DATAFILE=FILEREF

DBMS=XLSX

OUT=WORK.IMPORT;

GETNAMES=YES;

RUN;

data TreesSAS;

set import;

if Leave='Y' then Delete;

if row=1 then Delete;

if row=6 then Delete;

if Tree=1 then Delete;

if Tree=13 then Delete;

run;

Accepted Solutions

Solution

04-24-2018
04:52 PM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to AaronJ

04-24-2018 04:41 PM

@AaronJ wrote:

The Y / N variable is "Survival", simply a column indicating that the tree is alive.

So I took you up on your idea, and entered

if Survival= 'Y' then 1;

if Survival='N' then 0;

in the data step

and it gave me the Statement is not valid or used out of proper order error message.

How/where should i include this modification?

thanks

data TreesSAS;

set import;

if Leave='Y' then Delete;

if row=1 then Delete;

if row=6 then Delete;

if Tree=1 then Delete;

if Tree=13 then Delete;

if Survival='N' then 0;

if Survival='Y' then 1;

logGLD=log(GLD);

logDBH=log(DBH);

logHt=log(Ht);

run;

If you want to assign a value to a variable you have to reference the target variable:

Instead of:

if Survival='N' then 0;

if Survival='Y' then 1;

use:

if Survival='N' then SurvivalNum=0;

if Survival='Y' then SurvivalNum=1;

All Replies

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to AaronJ

04-23-2018 06:33 PM

Which variable(s) are coded Y N? Not at all clear.

Since you are already using a data step to modify your data it might be worth creating a numeric 0/1 coding (1=Y_.

Then go directly to proc means using the 0/1 coded variable. The mean will be the percentage of Y values with a corresponding deviation.

add a class statement to proc means to get summary statistics with in your groups.

Assuming you name that numeric variable SurvivalNum:

proc means data=treesSAS; class Species Measurement Fert Nfix; types Species Measurement Fert Nfix; var SurvivalNum; RUN;

the Types statement lets select combinations of things for the summary. You could add Species*Fert to get a summary of SurvivalNum for combinations of those two.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ballardw

04-23-2018 07:15 PM

The Y / N variable is "Survival", simply a column indicating that the tree is alive.

So I took you up on your idea, and entered

if Survival= 'Y' then 1;

if Survival='N' then 0;

in the data step

and it gave me the Statement is not valid or used out of proper order error message.

How/where should i include this modification?

thanks

data TreesSAS;

set import;

if Leave='Y' then Delete;

if row=1 then Delete;

if row=6 then Delete;

if Tree=1 then Delete;

if Tree=13 then Delete;

if Survival='N' then 0;

if Survival='Y' then 1;

logGLD=log(GLD);

logDBH=log(DBH);

logHt=log(Ht);

run;

Solution

04-24-2018
04:52 PM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to AaronJ

04-24-2018 04:41 PM

@AaronJ wrote:

The Y / N variable is "Survival", simply a column indicating that the tree is alive.

So I took you up on your idea, and entered

if Survival= 'Y' then 1;

if Survival='N' then 0;

in the data step

and it gave me the Statement is not valid or used out of proper order error message.

How/where should i include this modification?

thanks

data TreesSAS;

set import;

if Leave='Y' then Delete;

if row=1 then Delete;

if row=6 then Delete;

if Tree=1 then Delete;

if Tree=13 then Delete;

if Survival='N' then 0;

if Survival='Y' then 1;

logGLD=log(GLD);

logDBH=log(DBH);

logHt=log(Ht);

run;

If you want to assign a value to a variable you have to reference the target variable:

Instead of:

if Survival='N' then 0;

if Survival='Y' then 1;

use:

if Survival='N' then SurvivalNum=0;

if Survival='Y' then SurvivalNum=1;