Help using Base SAS procedures

Assigning value to a variable

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

Assigning value to a variable

I am attempting to analyse the incidence rates of diseases for different ethnicities. Currently ethnicity is coded as a double digit.

I want to analyses the rates of disease for different groups of Pacific Peoples. In the data itself there are multiple ethnic groups that fit under this. I am only interested in five pacific groups for analysis which are coded as follows:

 

samoan = 31

tongan = 32

cook island maori = 33

aggregated other pacific = 30, 34, 35, 36, 37

total pacific = 30, 31, 32, 33, 34, 35, 36, 37

 

I want to assign a value to each of the analysis groups (so samoan ends up as 1, tongan as 2, cookisland maori as 3, aggregated other pacific = 4 and lastly the total pacific group = 5). Is this possible? And if so what sort of expression would I use to do that.

 

The dataset looks as follow:

 

clientid     dob               ethnicgp     gender     domicilecode

63287     05/04/1987    34               M             0441

87234     18/11/1963    30               F              8823

09834      27/01/2000   37               F              3015

23432     03/07/1991    31               M             2125

 

Thanks in Advance


Accepted Solutions
Solution
‎02-16-2018 10:21 PM
Super User
Posts: 23,700

Re: Assigning value to a variable

A format or IF/THEN statement would work here.

Formats are better and easier to manage in my opinion.

 


acelini wrote:

I am attempting to analyse the incidence rates of diseases for different ethnicities. Currently ethnicity is coded as a double digit.

I want to analyses the rates of disease for different groups of Pacific Peoples. In the data itself there are multiple ethnic groups that fit under this. I am only interested in five pacific groups for analysis which are coded as follows:

 

samoan = 31

tongan = 32

cook island maori = 33

aggregated other pacific = 30, 34, 35, 36, 37

total pacific = 30, 31, 32, 33, 34, 35, 36, 37

 

I want to assign a value to each of the analysis groups (so samoan ends up as 1, tongan as 2, cookisland maori as 3, aggregated other pacific = 4 and lastly the total pacific group = 5). Is this possible? And if so what sort of expression would I use to do that.

 

The dataset looks as follow:

 

clientid     dob               ethnicgp     gender     domicilecode

63287     05/04/1987    34               M             0441

87234     18/11/1963    30               F              8823

09834      27/01/2000   37               F              3015

23432     03/07/1991    31               M             2125

 

Thanks in Advance


 

View solution in original post


All Replies
Solution
‎02-16-2018 10:21 PM
Super User
Posts: 23,700

Re: Assigning value to a variable

A format or IF/THEN statement would work here.

Formats are better and easier to manage in my opinion.

 


acelini wrote:

I am attempting to analyse the incidence rates of diseases for different ethnicities. Currently ethnicity is coded as a double digit.

I want to analyses the rates of disease for different groups of Pacific Peoples. In the data itself there are multiple ethnic groups that fit under this. I am only interested in five pacific groups for analysis which are coded as follows:

 

samoan = 31

tongan = 32

cook island maori = 33

aggregated other pacific = 30, 34, 35, 36, 37

total pacific = 30, 31, 32, 33, 34, 35, 36, 37

 

I want to assign a value to each of the analysis groups (so samoan ends up as 1, tongan as 2, cookisland maori as 3, aggregated other pacific = 4 and lastly the total pacific group = 5). Is this possible? And if so what sort of expression would I use to do that.

 

The dataset looks as follow:

 

clientid     dob               ethnicgp     gender     domicilecode

63287     05/04/1987    34               M             0441

87234     18/11/1963    30               F              8823

09834      27/01/2000   37               F              3015

23432     03/07/1991    31               M             2125

 

Thanks in Advance


 

SAS Super FREQ
Posts: 9,367

Re: Assigning value to a variable

Hi:
I second Reeza's comment. Multi-label formats are respected by several SAS procedures and are very handy for calculating the type of statistics you want. Here's an example using PROC REPORT and calculating the MEAN statistic http://go.documentation.sas.com/?docsetId=proc&docsetTarget=p1kkf0fl0y3yeon1qxyme7bp7hcn.htm&docsetV... and here is an example with TABULATE http://go.documentation.sas.com/?docsetId=proc&docsetVersion=9.4&docsetTarget=n0d6gp6j8o8592n1ai5e6t... and, here is a paper with a percent example on pages 7 and 8 http://www2.sas.com/proceedings/sugi31/249-31.pdf (it is an older paper, but the concepts are still good).

cynthia
Occasional Contributor
Posts: 5

Re: Assigning value to a variable

Posted in reply to Cynthia_sas

In attempting to create to do so I keep coming across an error.

 

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 proc format;
74 value ethnicgpfmt (notsorted);
NOTE: Format ETHNICGPFMT has been output.
75 31='Samoan'
__
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
 
76 32='Tongan'
77 33='Cook Island Maori'
78 30 ='Aggregated Other Pacific'
79 34-37='Aggregated Other Pacific'
80 21='NZ Maori'
81 10-12='Non Maori Pacific'
82 40-high='Non Maori Pacific';
NOTE: The previous statement has been deleted.
83 run;
 
 
What exactly is this error referring to?
 
 
SAS Super FREQ
Posts: 9,367

Re: Assigning value to a variable

[ Edited ]

Hi,
I believe you need to refer to the documentation for how to specify your values on the left side of the = sign. Here's the page: http://go.documentation.sas.com/?docsetId=proc&docsetTarget=n03qskwoints2an1ispy57plwrn9.htm&docsetV...

For example, it appears to me that code 76 and code 32 are 2 separate codes based on your previous posting -- and if they are, indeed 2 separate values, then they would need to be spectified as
76, 32 = 'Tongan' (note the 2 values are separated by commas)

cynthia

Super User
Posts: 23,700

Re: Assigning value to a variable

You don't need a semi colon after the VALUES statement, it's all one statement.

 


acelini wrote:

In attempting to create to do so I keep coming across an error.

 

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 proc format;
74 value ethnicgpfmt (notsorted); <- this is too early.
NOTE: Format ETHNICGPFMT has been output.
75 31='Samoan'
__
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
 
76 32='Tongan'
77 33='Cook Island Maori'
78 30 ='Aggregated Other Pacific'
79 34-37='Aggregated Other Pacific'
80 21='NZ Maori'
81 10-12='Non Maori Pacific'
82 40-high='Non Maori Pacific';
NOTE: The previous statement has been deleted.
83 run;
 
 
What exactly is this error referring to?
 
 

 

☑ This topic is solved.

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

Discussion stats
  • 5 replies
  • 311 views
  • 2 likes
  • 3 in conversation