<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how to create gender from social security number? in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/how-to-create-gender-from-social-security-number/m-p/419540#M4151</link>
    <description>&lt;P&gt;proc format does NOT create a new variable.&amp;nbsp; It only controls how a variable is displayed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your case&amp;nbsp;you need to create a new variable to which your new format can be displayed.&amp;nbsp; Assuming that the Danish social security number is a character variable, you can just retrieve the 11th character with the CHAR function, convert it to a numeric value, and then find the remainder after division by 2:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  value gender
    0="Female"
    1="Male";
run;

data t;
  input ssn $11.;
  g=input(char(ssn,11),1.);
  g=mod(g,2);
  format g gender.;
  put (_all_) (=);
datalines;
xxxxxx-xxx7
xxxxxx-xxx4
xxxxxx-xxx3
xxxxxx-xxx2
xxxxxx-xxx1
xxxxxx-xxx8
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 08 Dec 2017 12:23:30 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2017-12-08T12:23:30Z</dc:date>
    <item>
      <title>how to create gender from social security number?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/how-to-create-gender-from-social-security-number/m-p/419535#M4148</link>
      <description>&lt;P&gt;I need to create a gender variable from a Danish social security number. I am using SAS University edition for mac.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want my data to look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;social security number&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gender&lt;/P&gt;&lt;P&gt;xxxxxx-xxx7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;xxxxxx-xxx4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;xxxxxx-xxx3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;xxxxxx-xxx2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;xxxxxx-xxx1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;xxxxxx-xxx8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when the last digit is an even number it is a female and uneven number is a male.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have used proc format to create a new variable, but I that's all I have been able to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc format&lt;BR /&gt;value gender&lt;BR /&gt;0="Female"&lt;BR /&gt;1="Male";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 11:57:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/how-to-create-gender-from-social-security-number/m-p/419535#M4148</guid>
      <dc:creator>ansepans</dc:creator>
      <dc:date>2017-12-08T11:57:49Z</dc:date>
    </item>
    <item>
      <title>how to create gender from social security number?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/how-to-create-gender-from-social-security-number/m-p/419533#M4152</link>
      <description>&lt;P&gt;I need to create a gender variable from a Danish social security number.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want my data to look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;social security number&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gender&lt;/P&gt;&lt;P&gt;xxxxxx-xxx7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;xxxxxx-xxx4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;xxxxxx-xxx3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;xxxxxx-xxx2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;xxxxxx-xxx1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;xxxxxx-xxx8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when the last digit is an even number it is a female and uneven number is a male.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have used proc format to create a new variable, but I that's all I have been able to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc format&lt;BR /&gt;value gender&lt;BR /&gt;0="Female"&lt;BR /&gt;1="Male";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 11:56:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/how-to-create-gender-from-social-security-number/m-p/419533#M4152</guid>
      <dc:creator>ansepans</dc:creator>
      <dc:date>2017-12-08T11:56:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to create gender from social security number?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/how-to-create-gender-from-social-security-number/m-p/419537#M4149</link>
      <description>&lt;P&gt;like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input cpr $20.;
datalines;
280279-1667
280279-1668
280279-1667
;

data want;
	set have;
	if substr(cpr,length(cpr),1)in ("0","2","4","6","8") then gender=0;
	else gender=1; 
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Dec 2017 12:10:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/how-to-create-gender-from-social-security-number/m-p/419537#M4149</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-12-08T12:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to create gender from social security number?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/how-to-create-gender-from-social-security-number/m-p/419539#M4150</link>
      <description>&lt;P&gt;You can apply your format from your PROC FORMAT afterwards, but beware that you are missing a semicolon after PROC FORMAT statement. It should be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value gender
0="Female"
1="Male";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Dec 2017 12:15:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/how-to-create-gender-from-social-security-number/m-p/419539#M4150</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-12-08T12:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to create gender from social security number?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/how-to-create-gender-from-social-security-number/m-p/419540#M4151</link>
      <description>&lt;P&gt;proc format does NOT create a new variable.&amp;nbsp; It only controls how a variable is displayed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your case&amp;nbsp;you need to create a new variable to which your new format can be displayed.&amp;nbsp; Assuming that the Danish social security number is a character variable, you can just retrieve the 11th character with the CHAR function, convert it to a numeric value, and then find the remainder after division by 2:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  value gender
    0="Female"
    1="Male";
run;

data t;
  input ssn $11.;
  g=input(char(ssn,11),1.);
  g=mod(g,2);
  format g gender.;
  put (_all_) (=);
datalines;
xxxxxx-xxx7
xxxxxx-xxx4
xxxxxx-xxx3
xxxxxx-xxx2
xxxxxx-xxx1
xxxxxx-xxx8
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Dec 2017 12:23:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/how-to-create-gender-from-social-security-number/m-p/419540#M4151</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-12-08T12:23:30Z</dc:date>
    </item>
  </channel>
</rss>

