<?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: converting multiple numeric variables in to Character at once in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/converting-multiple-numeric-variables-in-to-Character-at-once/m-p/590695#M169110</link>
    <description>&lt;P&gt;You can't change the data type of a variable within a SAS data step. You need to create a new variable and assign the old variable while converting it (i.e. using a put function).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also can't reference a list of variable in an array the way you do it. You can use the automatic variable _character_ to reference all character variables at once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you search the communities here a bit then you'll find quite a few discussions around conversion of variables from numeric to character.&lt;/P&gt;</description>
    <pubDate>Sun, 22 Sep 2019 03:38:31 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2019-09-22T03:38:31Z</dc:date>
    <item>
      <title>converting multiple numeric variables in to Character at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-multiple-numeric-variables-in-to-Character-at-once/m-p/590687#M169107</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;I have a data set like this.&lt;BR /&gt;data RISKCLNS.RisksOnly_Apr17_Apr19(keep=REASON INSURANCE VISIT_DT PATIENT_ID _01_SEX_W_MALE _08_SEX_W_MAN_WH_SEX_W_MAN _02_SEX_W_FEMALE A__3_PARTNERS_IN_90_DAYS 
ALCOHOL_USE ANONYMOUS_SEX DRUG_USE DRUG_USE_MARIJUANA SEX_W_DRG_ETOH__NEVER_ SEX_W_NON_INJ_DRUG_USER SEX_W_DRG_ETOH_MOST_TIMES_ SEX_W_DRG_ETOH_SOMETIMES SEX_W_DRG_ETOH_MOST_TIMES
 SEX_W_DRG_ETOH__ALWAYS_ _06D_HAD_AN_STD_IN_PAST_3Y _06B_HAD_GC_IN_PAST_3_YRS  A_NO_PARTNERS_IN_90_DAYS A__2_PARTNERS_IN_90_DAYS NEW_PARTNER_LAST_VISIT SEX_W_PRTNR_MET_INTERNET
A__1_PARTNER_IN_90_DAYS _04_SEX_WHILE_USING_NON_ID A__4_9_PARTNRS_IN_90_DAYS RECTAL_INTERCOURSE ECSTACY__METHAMPHETAMINES
_10_SEX_PARTNERS_90_DAYS DRUG_USE_METHAMPHETAMINES  SEX_W_TRANSGENDER _07_SEX_W_IDU COCAINE_USE_SNORT _03_USING_USED_INJ_DRUGS
DRUG_USE_HEROIN COCAINE_USE_INJECT DRUG_USE_OPIOIDS SEX_FOR_DRUGS_MONEY GENDER_SP);
set RISKCLNS.KNNRSK_Apr17_Apr19 ;
run;&lt;BR /&gt;I want to convert all numeric variables into character. There are two character variables and rest of &lt;BR /&gt;variables are numeric. I used this code below, it did not work, Variables are still numeric,&lt;BR /&gt;
data want;
set RISKCLNS.RisksOnly_Apr17_Apr19;
array charn(41) PATIENT_ID _01_SEX_W_MALE _08_SEX_W_MAN_WH_SEX_W_MAN _02_SEX_W_FEMALE A__3_PARTNERS_IN_90_DAYS 
ALCOHOL_USE ANONYMOUS_SEX DRUG_USE DRUG_USE_MARIJUANA SEX_W_DRG_ETOH__NEVER_ SEX_W_NON_INJ_DRUG_USER SEX_W_DRG_ETOH_MOST_TIMES_ SEX_W_DRG_ETOH_SOMETIMES SEX_W_DRG_ETOH_MOST_TIMES
 SEX_W_DRG_ETOH__ALWAYS_ _06D_HAD_AN_STD_IN_PAST_3Y _06B_HAD_GC_IN_PAST_3_YRS  A_NO_PARTNERS_IN_90_DAYS A__2_PARTNERS_IN_90_DAYS NEW_PARTNER_LAST_VISIT SEX_W_PRTNR_MET_INTERNET
A__1_PARTNER_IN_90_DAYS _04_SEX_WHILE_USING_NON_ID A__4_9_PARTNRS_IN_90_DAYS RECTAL_INTERCOURSE ECSTACY__METHAMPHETAMINES
_10_SEX_PARTNERS_90_DAYS DRUG_USE_METHAMPHETAMINES  SEX_W_TRANSGENDER _07_SEX_W_IDU COCAINE_USE_SNORT _03_USING_USED_INJ_DRUGS
DRUG_USE_HEROIN COCAINE_USE_INJECT DRUG_USE_OPIOIDS SEX_FOR_DRUGS_MONEY GENDER_SP;
array charc(41) $12. PATIENT_ID1 - GENDER_SP41;
do i = 1 to 41;
charc(i)=put(charn(i),z11.);
end;
run;&lt;BR /&gt;&lt;BR /&gt;The&amp;nbsp;log&amp;nbsp;says&amp;nbsp;this:&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;156 data want;&lt;BR /&gt;157 set RISKCLNS.RisksOnly_Apr17_Apr19;&lt;BR /&gt;158 array charn(41) PATIENT_ID _01_SEX_W_MALE _08_SEX_W_MAN_WH_SEX_W_MAN _02_SEX_W_FEMALE&lt;BR /&gt;158! A__3_PARTNERS_IN_90_DAYS&lt;BR /&gt;159 ALCOHOL_USE ANONYMOUS_SEX DRUG_USE DRUG_USE_MARIJUANA SEX_W_DRG_ETOH__NEVER_&lt;BR /&gt;159! SEX_W_NON_INJ_DRUG_USER SEX_W_DRG_ETOH_MOST_TIMES_ SEX_W_DRG_ETOH_SOMETIMES&lt;BR /&gt;159! SEX_W_DRG_ETOH_MOST_TIMES&lt;BR /&gt;160 SEX_W_DRG_ETOH__ALWAYS_ _06D_HAD_AN_STD_IN_PAST_3Y _06B_HAD_GC_IN_PAST_3_YRS&lt;BR /&gt;160! A_NO_PARTNERS_IN_90_DAYS A__2_PARTNERS_IN_90_DAYS NEW_PARTNER_LAST_VISIT&lt;BR /&gt;160! SEX_W_PRTNR_MET_INTERNET&lt;BR /&gt;161 A__1_PARTNER_IN_90_DAYS _04_SEX_WHILE_USING_NON_ID A__4_9_PARTNRS_IN_90_DAYS&lt;BR /&gt;161! RECTAL_INTERCOURSE ECSTACY__METHAMPHETAMINES&lt;BR /&gt;162 _10_SEX_PARTNERS_90_DAYS DRUG_USE_METHAMPHETAMINES SEX_W_TRANSGENDER _07_SEX_W_IDU&lt;BR /&gt;162! COCAINE_USE_SNORT _03_USING_USED_INJ_DRUGS&lt;BR /&gt;163 DRUG_USE_HEROIN COCAINE_USE_INJECT DRUG_USE_OPIOIDS SEX_FOR_DRUGS_MONEY GENDER_SP;&lt;BR /&gt;ERROR: Too few variables defined for the dimension(s) specified for the array charn.&lt;BR /&gt;164 array charc(41) $12. PATIENT_ID1 - GENDER_SP41;&lt;BR /&gt;ERROR: Alphabetic prefixes for enumerated variables (PATIENT_ID1-GENDER_SP41) are different.&lt;BR /&gt;ERROR: Too few variables defined for the dimension(s) specified for the array charc.&lt;BR /&gt;165 do i = 1 to 41;&lt;BR /&gt;166 charc(i)=put(charn(i),z11.);&lt;BR /&gt;----&lt;BR /&gt;48&lt;BR /&gt;ERROR 48-59: The format $Z was not found or could not be loaded.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;167 end;&lt;BR /&gt;168 run;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;NOTE: Character values have been converted to numeric values at the places given by:&lt;BR /&gt;(Line):(Column).&lt;BR /&gt;166:1&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.WANT may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 41 variables.&lt;BR /&gt;WARNING: Data set WORK.WANT was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.50 seconds&lt;BR /&gt;cpu time 0.03 seconds&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 22 Sep 2019 02:19:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-multiple-numeric-variables-in-to-Character-at-once/m-p/590687#M169107</guid>
      <dc:creator>Dhana18</dc:creator>
      <dc:date>2019-09-22T02:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: converting multiple numeric variables in to Character at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-multiple-numeric-variables-in-to-Character-at-once/m-p/590695#M169110</link>
      <description>&lt;P&gt;You can't change the data type of a variable within a SAS data step. You need to create a new variable and assign the old variable while converting it (i.e. using a put function).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also can't reference a list of variable in an array the way you do it. You can use the automatic variable _character_ to reference all character variables at once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you search the communities here a bit then you'll find quite a few discussions around conversion of variables from numeric to character.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Sep 2019 03:38:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-multiple-numeric-variables-in-to-Character-at-once/m-p/590695#M169110</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-09-22T03:38:31Z</dc:date>
    </item>
  </channel>
</rss>

