How to learn SAS codes

Reply
New Contributor
Posts: 2

How to learn SAS codes

Hi I am new to SAS and code and VERY frustrated.  I am trying to create 2+ anova for homework problems out of 3rd edition "Statistical Methods"

authors -freund, Wilson, mohr

my teacher likes to provide output for interpretation, and gives word document turorials but does not show any sas code anywhere, it is very frustrating.

Here is what I tried to use for code and not getting much for output, I hope someone can help me:

This is for exercise 9.11 in the book

   six rats were randomly assigned to 10 diets; the first 9 diets are the nine combinations of the two sets of three factor levels and diet 10 is control diet.  The response variable is the BV (biological value)

*I used "control" and "c" in for the control group, can I leave it blank, like the data provided did?

perform appropriate analysis to determine the effect of grain and preparation types.  (this is a factorial experiment plus a control level).  One approach is to analyze the factorial and then perform one-way for the first 10 treatments with a contrast for control versus all others.

Well I cannot even generate SAS output!!!!  HELP!  Smiley Happy

data
GRAINS;

input
trt$ grain$ prep$ BV;

datalines;

1     sorgh whole 40.61

1     sorgh whole 56.78

1     sorgh whole 69.05

1     sorgh whole 39.9

1     sorgh whole 55.06

1     sorgh whole 32.43

 

2     sorgh decort      74.68

2     sorgh decort      56.33

2     sorgh decort      71.02

2     sorgh decort      53.35

2     sorgh decort      41.43

2     sorgh decort      33

3     sorgh bsb   71.6

3     sorgh bsb   62.64

3     sorgh bsb   78.95

3     sorgh bsb   69.86

3     sorgh bsb   60.26

3     sorgh bsb   67.05

4     lysine      whole 42.46

4     lysine      whole 50.78

4     lysine      whole 48.88

4     lysine      whole 44.12

4     lysine      whole 48.86

4     lysine      whole 43.39

5     lysine      decort      50.11

5     lysine      decort      57.46

5     lysine      decort      55.36

5     lysine      decort      57.28

5     lysine      decort      51.6

5     lysine      decort      53.96

6     lysine      bsb   60.57

6     lysine      bsb   62.62

6     lysine      bsb   66.2

6     lysine      bsb   54.32

6     lysine      bsb   47.11

6     lysine      bsb   41.56

7     millet      whole 45.58

7     millet      whole 68.51

7     millet      whole 54.13

7     millet      whole 45.15

7     millet      whole 45.03

7     millet      whole 39.72

8     millet      decort      46.19

8     millet      decort      45.54

8     millet      decort      42.57

8     millet      decort      30.23

8     millet      decort      38.83

8     millet      decort      40.28

9     millet      bsb   64.27

9     millet      bsb   56.48

9     millet      bsb   73.24

9     millet      bsb   67.18

9     millet      bsb   51.11

9     millet      bsb   32.97

10    control     c           87.77

10    control c         91.8

10    control c         81.13

10    control c         80.88

10    control c         66.06

10    control c         73.36

run;

Trusted Advisor
Posts: 3,212

Re: How to learn SAS codes

Think you are needing some SAS basics course first.

---->-- ja karman --<-----
Super User
Posts: 19,770

Re: How to learn SAS codes

Step 1, input data. You need a semicolon after then last line, before the run to tell SAS the input has finished, that will allow you to import your data.

Step 2, determine your analysis - are you doing an ANOVA, TTEST, Regression?

Step 3, Google the type of analysis on Lexjansen.com and you'll find a lot of papers with example code on how to run your analysis.  Feel free to post back if you have issues at this point.

There's a few better books out there than cover the SAS side of things, but you probably don't have time to learn both if its for a University Course.


Good Luck Smiley Happy

data
GRAINS;

input
trt$ grain$ prep$ BV;

datalines;

1     sorgh whole 40.61

1     sorgh whole 56.78

1     sorgh whole 69.05

1     sorgh whole 39.9

1     sorgh whole 55.06

1     sorgh whole 32.43

2     sorgh decort      74.68

2     sorgh decort      56.33

2     sorgh decort      71.02

2     sorgh decort      53.35

2     sorgh decort      41.43

2     sorgh decort      33

3     sorgh bsb   71.6

3     sorgh bsb   62.64

3     sorgh bsb   78.95

3     sorgh bsb   69.86

3     sorgh bsb   60.26

3     sorgh bsb   67.05

4     lysine      whole 42.46

4     lysine      whole 50.78

4     lysine      whole 48.88

4     lysine      whole 44.12

4     lysine      whole 48.86

4     lysine      whole 43.39

5     lysine      decort      50.11

5     lysine      decort      57.46

5     lysine      decort      55.36

5     lysine      decort      57.28

5     lysine      decort      51.6

5     lysine      decort      53.96

6     lysine      bsb   60.57

6     lysine      bsb   62.62

6     lysine      bsb   66.2

6     lysine      bsb   54.32

6     lysine      bsb   47.11

6     lysine      bsb   41.56

7     millet      whole 45.58

7     millet      whole 68.51

7     millet      whole 54.13

7     millet      whole 45.15

7     millet      whole 45.03

7     millet      whole 39.72

8     millet      decort      46.19

8     millet      decort      45.54

8     millet      decort      42.57

8     millet      decort      30.23

8     millet      decort      38.83

8     millet      decort      40.28

9     millet      bsb   64.27

9     millet      bsb   56.48

9     millet      bsb   73.24

9     millet      bsb   67.18

9     millet      bsb   51.11

9     millet      bsb   32.97

10    control     c           87.77

10    control c         91.8

10    control c         81.13

10    control c         80.88

10    control c         66.06

10    control c         73.36

;

run;

New Contributor
Posts: 2

Re: How to learn SAS codes

Thanks Jaap that was the exact reason I was posting on here, to get some basics.  Usually my teacher's dummy codes allow me to fill in the blanks but for two way anova/factorials none of his codes are working and he refuses to help.  Everyone in my class is using JMP except me.

Reeza, I would love to have a book or two that will help me.  Since my teacher refuses to help and claims "debugging SAS code builds character...."  HA really funny.  Anyway I will need to learn SAS code to utilize it with my research project for my Master's degree.  So I would definitely be interested in purchasing something (ANYTHING) to help me.

Super User
Posts: 19,770

Re: How to learn SAS codes

I googled 2 way ANOVA/Factorial and found results on LexJansen.com so there's definitely code out there.

If you want a book to buy I guess I'd recommend something like the following:

A Handbook of Statistical Analyses using SAS, Third Edition

or Statistical Programming in SAS.

If you're affiliated with a University you probably have library access and can access the books online for free through Safari Online books.

Trusted Advisor
Posts: 3,212

Re: How to learn SAS codes

@rlsatt, You have got good references from reeza.

You have a challenge to pickup in a short fast time using SAS. There is a need to focus on the aspects for your area/course. By the way, JMP is also from SAS-institute.  
If you have some programming experience that could help. The best thing is running the code samples whatever you need to get your statistical education program succeed.

The usage of the ; is very important in the SAS coding (as in many other languages) with some others. Experienced SAS people have got trained to recognize mistakes (as reeza) and some tricks arround them. The Enhanced editor (SAS DMS and Eguide) should help you a lot with that.    

   

The SAS documentation is good accessible SAS 9.4 Programmer's Bookshelf. A quick review on the concepts can give some addtional background for coding.       

---->-- ja karman --<-----
Ask a Question
Discussion stats
  • 5 replies
  • 246 views
  • 1 like
  • 3 in conversation