BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kazik_vip
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
stat_sas
Ammonite | Level 13

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

7 REPLIES 7
Reeza
Super User

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

ballardw
Super User

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

kazik_vip
Calcite | Level 5

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?

ballardw
Super User

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.

stat_sas
Ammonite | Level 13

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;

kazik_vip
Calcite | Level 5

Thank you all for help!.

Reeza
Super User

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 7 replies
  • 1087 views
  • 3 likes
  • 4 in conversation