<?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: Create a new variable that adds the character “_&amp;quot; in front of the values of an existing var in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Create-a-new-variable-that-adds-the-character-quot-in-front-of/m-p/904523#M40394</link>
    <description>&lt;P&gt;Certainly much easier to do in SAS than in Excel.&amp;nbsp; No pointing or clicking required.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   length _va $15 ;
   _va=cats('_',va);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can also use the PUT() function to control how the number is converted to a string.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you know VA should have positive values values less than 10 then you probably want to use the 6.4 format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   length _va $7;
   _va=cats('_',put(va,6.4));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 25 Nov 2023 18:10:28 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-11-25T18:10:28Z</dc:date>
    <item>
      <title>Create a new variable that adds the character “_" in front of the values of an existing variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-a-new-variable-that-adds-the-character-quot-in-front-of/m-p/904508#M40391</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I need to create a new variable that adds the character “_" in front of the value of an existing variable.&amp;nbsp; I find this easy to do in Excel, but I cannot&amp;nbsp; do it in SAS.&lt;/P&gt;
&lt;P&gt;An example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what I have&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; have&amp;nbsp; &amp;nbsp;; input&amp;nbsp; date&amp;nbsp; va&amp;nbsp;&amp;nbsp; vb&amp;nbsp; $;&lt;/P&gt;
&lt;P&gt;cards&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;20000630&amp;nbsp;&amp;nbsp;&amp;nbsp; 6.1207&amp;nbsp;&amp;nbsp; to&lt;/P&gt;
&lt;P&gt;20000929&amp;nbsp;&amp;nbsp;&amp;nbsp; 6.1158&amp;nbsp;&amp;nbsp; ri&lt;/P&gt;
&lt;P&gt;20001229&amp;nbsp;&amp;nbsp;&amp;nbsp; 5.7898&amp;nbsp;&amp;nbsp; to&lt;/P&gt;
&lt;P&gt;20010330&amp;nbsp;&amp;nbsp;&amp;nbsp; 4.9815&amp;nbsp;&amp;nbsp; co&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to generate new variable _va that adds _ to the values of the existing variable&amp;nbsp; va.&lt;/P&gt;
&lt;P&gt;So, I would &amp;nbsp;like to have this:&lt;/P&gt;
&lt;P&gt;data want&lt;/P&gt;
&lt;P&gt;Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;va&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _va&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; vb&lt;/P&gt;
&lt;P&gt;20000630&amp;nbsp;&amp;nbsp;&amp;nbsp; 6.1207&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _6.1207&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; to&lt;/P&gt;
&lt;P&gt;20000929&amp;nbsp;&amp;nbsp;&amp;nbsp; 6.1158 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _3.1158&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;ri&lt;/P&gt;
&lt;P&gt;20001229&amp;nbsp;&amp;nbsp;&amp;nbsp; 5.7898 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _5.7898&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;to&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;20010330&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;4.9815&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _4.9815&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;co&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Thank you for your help&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Nov 2023 11:38:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-a-new-variable-that-adds-the-character-quot-in-front-of/m-p/904508#M40391</guid>
      <dc:creator>Thomas_mp</dc:creator>
      <dc:date>2023-11-25T11:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable that adds the character “_" in front of the values of an existing var</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-a-new-variable-that-adds-the-character-quot-in-front-of/m-p/904510#M40392</link>
      <description>&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/da/vdmmlcdc/8.1/lefunctionsref/n1e21rr6al5m2nn19r1fat5qxwrt.htm#:~:text=Removes%20leading%20and%20trailing%20blanks%2C%20and%20returns%20a%20concatenated%20character%20string.&amp;amp;text=Restriction%3A,%2C%20and%20MBCS%20(UTF8)" target="_blank"&gt;https://documentation.sas.com/doc/da/vdmmlcdc/8.1/lefunctionsref/n1e21rr6al5m2nn19r1fat5qxwrt.htm#:~:text=Removes%20leading%20and%20trailing%20blanks%2C%20and%20returns%20a%20concatenated%20character%20string.&amp;amp;text=Restriction%3A,%2C%20and%20MBCS%20(UTF8)&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Nov 2023 12:57:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-a-new-variable-that-adds-the-character-quot-in-front-of/m-p/904510#M40392</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2023-11-25T12:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable that adds the character “_" in front of the values of an existing var</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-a-new-variable-that-adds-the-character-quot-in-front-of/m-p/904511#M40393</link>
      <description>Doing what you ask should be as simple as:&lt;BR /&gt;_va = catt("_", va);&lt;BR /&gt;However, you have to realize that your new variable must be a character variable.  Numeric variables cannot contain an underscore.   Other approaches are worth considering, such as a picture format that contains a prefix of an underscore, but leaves the actual value as numeric.  You would have to describe what happens next, to get a more insightful answer.  What are your plans for using _va?.&lt;BR /&gt;&lt;BR /&gt;Also note, it would be worth learning how SAS handles dates.  Instead of an 8 digit number, there is a better way to go.</description>
      <pubDate>Sat, 25 Nov 2023 13:19:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-a-new-variable-that-adds-the-character-quot-in-front-of/m-p/904511#M40393</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2023-11-25T13:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable that adds the character “_" in front of the values of an existing var</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-a-new-variable-that-adds-the-character-quot-in-front-of/m-p/904523#M40394</link>
      <description>&lt;P&gt;Certainly much easier to do in SAS than in Excel.&amp;nbsp; No pointing or clicking required.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   length _va $15 ;
   _va=cats('_',va);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can also use the PUT() function to control how the number is converted to a string.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you know VA should have positive values values less than 10 then you probably want to use the 6.4 format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   length _va $7;
   _va=cats('_',put(va,6.4));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 Nov 2023 18:10:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-a-new-variable-that-adds-the-character-quot-in-front-of/m-p/904523#M40394</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-11-25T18:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable that adds the character “_" in front of the values of an existing var</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-a-new-variable-that-adds-the-character-quot-in-front-of/m-p/904794#M40402</link>
      <description>&lt;P&gt;I am curious: what is the use-case requiring numeric values being prefixed with an underscore?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2023 07:01:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-a-new-variable-that-adds-the-character-quot-in-front-of/m-p/904794#M40402</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2023-11-28T07:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new variable that adds the character “_" in front of the values of an existing var</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-a-new-variable-that-adds-the-character-quot-in-front-of/m-p/904809#M40403</link>
      <description>&lt;P&gt;Thank you Tom !!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2023 10:33:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-a-new-variable-that-adds-the-character-quot-in-front-of/m-p/904809#M40403</guid>
      <dc:creator>Thomas_mp</dc:creator>
      <dc:date>2023-11-28T10:33:30Z</dc:date>
    </item>
  </channel>
</rss>

