<?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: I see blank spaces when i convert from numeric to character in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/I-see-blank-spaces-when-i-convert-from-numeric-to-character/m-p/766733#M30686</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/394970"&gt;@Banke&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;thanks. here is what i did&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i had initially converted recoded race and sex which had values of 0 and 1 in the original file into 'white and black' and male and female'/ i then noticed they showed as numeric variable when i ran the proc content.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i then wanted to convert them into character variables using&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA BIOSTAT.KEEP7;&lt;BR /&gt;SET BIOSTAT.KEEP2;&lt;BR /&gt;SEX = PUT (SEX, BEST5.);&lt;BR /&gt;RACE = PUT (RACE, BEST5.);&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;it worked but&amp;nbsp; showed up as rnew variables (race_character and sex_character in my file biostat.keep7) and the coding was the original 0 and 1 as shown in the first picture (blakc and white, male and female).&lt;/P&gt;
&lt;P&gt;i then wanted to convert back to the formatted style of black and white, male and female using the following syntax&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA BIOSTAT.KEEP10;&lt;BR /&gt;SET BIOSTAT.KEEP7;&lt;BR /&gt;OPTIONS FMTSEARCH= (BIOSTAT.FORMATS);&lt;BR /&gt;FORMAT $SEX_CHARACTER $SEX_A. $RACE_CHARACTER $RACE_A.;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;$SEX_CHARACTER and&amp;nbsp; $RACE_CHARACTER . are the new variable creater after conversion to character&lt;/P&gt;
&lt;P&gt;$SEX_A and&amp;nbsp;$RACE_A are the formats i created (white and black, male and female)&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;First. You cannot change the variable type with code like : sex = put(sex,best5.) . If sex is numeric you will get a bit in the log (you do read your logs don't you ?) that reads like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column)
&lt;/PRE&gt;
&lt;P&gt;because Sex is numeric and you are attempting to place a character value into it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, if you had created a new variable, and likely your variables, would have leading spaces. If the original value was 1, then the character value is going to have 4 leading spaces.&lt;/P&gt;
&lt;P&gt;You do not show the code you used to create the format but if you did not have the corresponding leading spaces it likely doesn't work as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The line&lt;/P&gt;
&lt;PRE&gt;FORMAT $SEX_CHARACTER $SEX_A. $RACE_CHARACTER $RACE_A.;&lt;/PRE&gt;
&lt;P&gt;did not associate your format because $SEX_CHARACTER and&amp;nbsp; $RACE_CHARACTER are not a valid variable names and your log should have notes to that effect&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hint: Rerun the code with the assignments, the format creation and the assignment. The go to the log, copy the text from the first data step through the last with all of the notes, warnings and errors. Then on the forum open a text box by clicking on the &amp;lt;/&amp;gt; icon above the message window and pasting all the copied text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Sep 2021 00:26:25 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-09-09T00:26:25Z</dc:date>
    <item>
      <title>I see blank spaces when i convert from numeric to character</title>
      <link>https://communities.sas.com/t5/New-SAS-User/I-see-blank-spaces-when-i-convert-from-numeric-to-character/m-p/766705#M30674</link>
      <description>&lt;P&gt;Hello all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i successfully recoded my data which we initially o and 1 into white and black, and male and female under the sex and race column but the proc content shows that it is numeric. i am trying to convert to character, but when i run the syntax, it comes out blank as shown in the second picture. what could be wrong please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is my syntax ($SEX_NEW and $RACE_NEW are the formats i created in my library)&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="after i converted race and sex to character, i got new variables but in the original format of 0 and 1" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63407iBAC35F462890F575/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot (316).png" alt="after i converted race and sex to character, i got new variables but in the original format of 0 and 1" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;after i converted race and sex to character, i got new variables but in the original format of 0 and 1&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nothing is appearing . i am expecting the black and white, male and female" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63409i2806CABCE8BFA877/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot (318).png" alt="nothing is appearing . i am expecting the black and white, male and female" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;nothing is appearing . i am expecting the black and white, male and female&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DATA BIOSTAT.KEEP10;&lt;BR /&gt;SET BIOSTAT.KEEP5;&lt;BR /&gt;OPTIONS FMTSEARCH= (BIOSTAT.FORMATS);&lt;BR /&gt;FORMAT SEX_CHARACTER $SEX_NEW. RACE_CHARACTER $RACE_NEW.;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 21:33:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/I-see-blank-spaces-when-i-convert-from-numeric-to-character/m-p/766705#M30674</guid>
      <dc:creator>Banke</dc:creator>
      <dc:date>2021-09-08T21:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: I see blank spaces when i convert from numeric to character</title>
      <link>https://communities.sas.com/t5/New-SAS-User/I-see-blank-spaces-when-i-convert-from-numeric-to-character/m-p/766706#M30675</link>
      <description>&lt;P&gt;Why are you converting sex and race to character?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 21:39:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/I-see-blank-spaces-when-i-convert-from-numeric-to-character/m-p/766706#M30675</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-09-08T21:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: I see blank spaces when i convert from numeric to character</title>
      <link>https://communities.sas.com/t5/New-SAS-User/I-see-blank-spaces-when-i-convert-from-numeric-to-character/m-p/766707#M30676</link>
      <description>&lt;P&gt;HI SASKIWI,&lt;/P&gt;&lt;P&gt;i want to convert because of when i want to do inferential statistics.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 21:40:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/I-see-blank-spaces-when-i-convert-from-numeric-to-character/m-p/766707#M30676</guid>
      <dc:creator>Banke</dc:creator>
      <dc:date>2021-09-08T21:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: I see blank spaces when i convert from numeric to character</title>
      <link>https://communities.sas.com/t5/New-SAS-User/I-see-blank-spaces-when-i-convert-from-numeric-to-character/m-p/766709#M30677</link>
      <description>&lt;P&gt;Can you provide an example of those? There shouldn't be a problem just leaving them as numeric and just applying a numeric format to them if you want them to show with text descriptions.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 21:54:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/I-see-blank-spaces-when-i-convert-from-numeric-to-character/m-p/766709#M30677</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-09-08T21:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: I see blank spaces when i convert from numeric to character</title>
      <link>https://communities.sas.com/t5/New-SAS-User/I-see-blank-spaces-when-i-convert-from-numeric-to-character/m-p/766710#M30678</link>
      <description>&lt;P&gt;You need to show how you convert the values from numeric to character &lt;STRONG&gt;and&lt;/STRONG&gt; the definitions of the formats.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some possibilities involve creating character values with leading spaces and a format that doesn't display those converted values as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a hard time seeing what you need the character value for as pretty much anything that will work with a character value will work with a numeric value and format to display desired text.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 21:57:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/I-see-blank-spaces-when-i-convert-from-numeric-to-character/m-p/766710#M30678</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-09-08T21:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: I see blank spaces when i convert from numeric to character</title>
      <link>https://communities.sas.com/t5/New-SAS-User/I-see-blank-spaces-when-i-convert-from-numeric-to-character/m-p/766712#M30679</link>
      <description>&lt;P&gt;thanks. I want to use chi square to find association between BMI and sex, race and age at the univariate level. Because &amp;nbsp;race and sex are qualitative in nature, i thought i should convert them tom categorical variables. for my descriptive stats, will SAS run a bar chart with a numerical value?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 22:02:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/I-see-blank-spaces-when-i-convert-from-numeric-to-character/m-p/766712#M30679</guid>
      <dc:creator>Banke</dc:creator>
      <dc:date>2021-09-08T22:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: I see blank spaces when i convert from numeric to character</title>
      <link>https://communities.sas.com/t5/New-SAS-User/I-see-blank-spaces-when-i-convert-from-numeric-to-character/m-p/766715#M30680</link>
      <description>&lt;P&gt;thanks. here is what i did&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i had initially converted recoded race and sex which had values of 0 and 1 in the original file into 'white and black' and male and female'/ i then noticed they showed as numeric variable when i ran the proc content.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i then wanted to convert them into character variables using&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA BIOSTAT.KEEP7;&lt;BR /&gt;SET BIOSTAT.KEEP2;&lt;BR /&gt;SEX = PUT (SEX, BEST5.);&lt;BR /&gt;RACE = PUT (RACE, BEST5.);&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;it worked but&amp;nbsp; showed up as rnew variables (race_character and sex_character in my file biostat.keep7) and the coding was the original 0 and 1 as shown in the first picture (blakc and white, male and female).&lt;/P&gt;&lt;P&gt;i then wanted to convert back to the formatted style of black and white, male and female using the following syntax&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA BIOSTAT.KEEP10;&lt;BR /&gt;SET BIOSTAT.KEEP7;&lt;BR /&gt;OPTIONS FMTSEARCH= (BIOSTAT.FORMATS);&lt;BR /&gt;FORMAT $SEX_CHARACTER $SEX_A. $RACE_CHARACTER $RACE_A.;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$SEX_CHARACTER and&amp;nbsp; $RACE_CHARACTER . are the new variable creater after conversion to character&lt;/P&gt;&lt;P&gt;$SEX_A and&amp;nbsp;$RACE_A are the formats i created (white and black, male and female)&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 22:12:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/I-see-blank-spaces-when-i-convert-from-numeric-to-character/m-p/766715#M30680</guid>
      <dc:creator>Banke</dc:creator>
      <dc:date>2021-09-08T22:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: I see blank spaces when i convert from numeric to character</title>
      <link>https://communities.sas.com/t5/New-SAS-User/I-see-blank-spaces-when-i-convert-from-numeric-to-character/m-p/766733#M30686</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/394970"&gt;@Banke&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;thanks. here is what i did&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i had initially converted recoded race and sex which had values of 0 and 1 in the original file into 'white and black' and male and female'/ i then noticed they showed as numeric variable when i ran the proc content.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i then wanted to convert them into character variables using&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA BIOSTAT.KEEP7;&lt;BR /&gt;SET BIOSTAT.KEEP2;&lt;BR /&gt;SEX = PUT (SEX, BEST5.);&lt;BR /&gt;RACE = PUT (RACE, BEST5.);&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;it worked but&amp;nbsp; showed up as rnew variables (race_character and sex_character in my file biostat.keep7) and the coding was the original 0 and 1 as shown in the first picture (blakc and white, male and female).&lt;/P&gt;
&lt;P&gt;i then wanted to convert back to the formatted style of black and white, male and female using the following syntax&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA BIOSTAT.KEEP10;&lt;BR /&gt;SET BIOSTAT.KEEP7;&lt;BR /&gt;OPTIONS FMTSEARCH= (BIOSTAT.FORMATS);&lt;BR /&gt;FORMAT $SEX_CHARACTER $SEX_A. $RACE_CHARACTER $RACE_A.;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;$SEX_CHARACTER and&amp;nbsp; $RACE_CHARACTER . are the new variable creater after conversion to character&lt;/P&gt;
&lt;P&gt;$SEX_A and&amp;nbsp;$RACE_A are the formats i created (white and black, male and female)&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;First. You cannot change the variable type with code like : sex = put(sex,best5.) . If sex is numeric you will get a bit in the log (you do read your logs don't you ?) that reads like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column)
&lt;/PRE&gt;
&lt;P&gt;because Sex is numeric and you are attempting to place a character value into it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, if you had created a new variable, and likely your variables, would have leading spaces. If the original value was 1, then the character value is going to have 4 leading spaces.&lt;/P&gt;
&lt;P&gt;You do not show the code you used to create the format but if you did not have the corresponding leading spaces it likely doesn't work as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The line&lt;/P&gt;
&lt;PRE&gt;FORMAT $SEX_CHARACTER $SEX_A. $RACE_CHARACTER $RACE_A.;&lt;/PRE&gt;
&lt;P&gt;did not associate your format because $SEX_CHARACTER and&amp;nbsp; $RACE_CHARACTER are not a valid variable names and your log should have notes to that effect&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hint: Rerun the code with the assignments, the format creation and the assignment. The go to the log, copy the text from the first data step through the last with all of the notes, warnings and errors. Then on the forum open a text box by clicking on the &amp;lt;/&amp;gt; icon above the message window and pasting all the copied text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 00:26:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/I-see-blank-spaces-when-i-convert-from-numeric-to-character/m-p/766733#M30686</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-09-09T00:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: I see blank spaces when i convert from numeric to character</title>
      <link>https://communities.sas.com/t5/New-SAS-User/I-see-blank-spaces-when-i-convert-from-numeric-to-character/m-p/766757#M30691</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/394970"&gt;@Banke&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;HI SASKIWI,&lt;/P&gt;
&lt;P&gt;i want to convert because of when i want to do inferential statistics.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why would it matter whether the variable has 0/1 or "male"/"female" for statistics?&lt;/P&gt;
&lt;P&gt;What PROC are you using?&lt;/P&gt;
&lt;P&gt;Doesn't it support the CLASS statement?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 03:19:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/I-see-blank-spaces-when-i-convert-from-numeric-to-character/m-p/766757#M30691</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-09-09T03:19:57Z</dc:date>
    </item>
  </channel>
</rss>

