Help using Base SAS procedures

Problem with data analysis

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Problem with data analysis

Hi everybody,

I have such table:

Age

Unemployment time

to 1

1-3

3-6

6-12

12-24

Up 24

18-24

12

15

10

10

6

5

25-34

11

18

17

19

16

29

35-44

8

12

12

15

13

33

45-54

7

12

13

16

16

49

55-59

1

2

2

4

4

15

60-69

0

0

0

1

1

3

It shows how much people in different age are unemployment. I need to find out if there is statistical relation between age and unemployment time. Please tell me how to do that? To make chi square test the table looks incorrect and I can't change the table into proper look. Could somebody help me? proc


Accepted Solutions
Solution
‎09-25-2014 08:23 PM
Trusted Advisor
Posts: 1,204

Re: Problem with data analysis

May be this can generate the desired results.

data want;
input f age_group $ unemployment $;
datalines;
12 18-24 0-1
15 18-24 1-3
10 18-24 3-6
10 18-24 6-12
6 18-24 12-24
5 18-24 Up-24
11 25-34 0-1
18 25-34 1-3
17 25-34 3-6
19 25-34 6-12
16 25-34 12-24
29 25-34 Up-24
8 35-44 0-1
12 35-44 1-3
12 35-44 3-6
15 35-44 6-12
13 35-44 12-24
33 35-44 Up-24
7 44-54 0-1
12 44-54 1-3
13 44-54 3-6
16 44-54 6-12
16 44-54 12-24
49 44-54 Up-24
1 55-59 0-1
2 55-59 1-3
2 55-59 3-6
4 55-59 6-12
4 55-59 12-24
15 55-59 Up-24
0 60-69 0-1
0 60-69 1-3
0 60-69 3-6
1 60-69 6-12
1 60-69 12-24
3 60-69 Up-24
;

proc freq data=want;
weight f;
table age_group*unemployment/norow nocol nopercent chisq;
run;

View solution in original post


All Replies
Super User
Posts: 17,828

Re: Problem with data analysis

What exactly is your question?

You will need to do a Fishers exact test instead of a Chi Square test because you have cells that are less than 5.  Proc Freq is what you're looking for.

Check the documentation on how to deal with data that already has counts, i.e. using the weight statement.

Base SAS(R) 9.2 Procedures Guide: Statistical Procedures, Third Edition

Super User
Posts: 10,500

Re: Problem with data analysis

Are you asking how to make a data set from the table information that can be used with proc freq or other procedures?

New Contributor
Posts: 3

Re: Problem with data analysis

Yes, I am asking how to make a data set from this table that can be used with proc freq to check the statistical relation using chi square. Or how to check the statistical relation using another method?

Super User
Posts: 10,500

Re: Problem with data analysis

data want;

   input agegroup $ 1-5 @;

   do period = 1 to 6;

      input count @;

      output;

   end;

   input;

datalines;

18-24 12 15 10 10 6 5

25-34 11 18 17 19 16 29

35-44 8 12 12 15 13 33

45-54 7 12 13 16 16 49

55-59 1 2 2 4 4 15

60-69 0 0 0 1 1 3

;

run;

proc format;

value period

1 = 'to 1'

2 = '1-3'

3='3-6'

4='6-12'

5='12-24'

6='Up 24'

;

run;

If you want the period to be closer to a value that could be used as duration then change the period values from 1 to 6 to period = 0,2,4.5, 9,18 and 24 or so. Then the period roughly corresponds to an actual interval. We could  also read in agemin and agemax and calculate a midpoint for age.

Solution
‎09-25-2014 08:23 PM
Trusted Advisor
Posts: 1,204

Re: Problem with data analysis

May be this can generate the desired results.

data want;
input f age_group $ unemployment $;
datalines;
12 18-24 0-1
15 18-24 1-3
10 18-24 3-6
10 18-24 6-12
6 18-24 12-24
5 18-24 Up-24
11 25-34 0-1
18 25-34 1-3
17 25-34 3-6
19 25-34 6-12
16 25-34 12-24
29 25-34 Up-24
8 35-44 0-1
12 35-44 1-3
12 35-44 3-6
15 35-44 6-12
13 35-44 12-24
33 35-44 Up-24
7 44-54 0-1
12 44-54 1-3
13 44-54 3-6
16 44-54 6-12
16 44-54 12-24
49 44-54 Up-24
1 55-59 0-1
2 55-59 1-3
2 55-59 3-6
4 55-59 6-12
4 55-59 12-24
15 55-59 Up-24
0 60-69 0-1
0 60-69 1-3
0 60-69 3-6
1 60-69 6-12
1 60-69 12-24
3 60-69 Up-24
;

proc freq data=want;
weight f;
table age_group*unemployment/norow nocol nopercent chisq;
run;

New Contributor
Posts: 3

Re: Problem with data analysis

Thank you all for help!.

Super User
Posts: 17,828

Re: Problem with data analysis

You can't use chi-square as the SAS notes will tell you...

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 247 views
  • 3 likes
  • 4 in conversation