<?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 variable from multiple sources in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-variable-from-multiple-sources/m-p/774868#M246307</link>
    <description>&lt;P&gt;You can't use + for character strings, because SAS thinks + is addition of numeric variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you want is the CATS function. See the example at &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lefunctionsref/n1e21rr6al5m2nn19r1fat5qxwrt.htm" target="_blank" rel="noopener"&gt;https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lefunctionsref/n1e21rr6al5m2nn19r1fat5qxwrt.htm&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Oct 2021 12:34:14 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-10-18T12:34:14Z</dc:date>
    <item>
      <title>Create variable from multiple sources</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-variable-from-multiple-sources/m-p/774866#M246306</link>
      <description>&lt;P&gt;I need to create a record header containing static data and defined variables. This header needs to be wrapped in quotes:&lt;/P&gt;
&lt;P&gt;"CSR+nnnnnnnnnnnnnn012cccccccccccc"&lt;/P&gt;
&lt;P&gt;The CSR+ is static defined data.&lt;/P&gt;
&lt;P&gt;The first eight and second eight following numerics are dates (yyyymmdd) from defined variables.&lt;/P&gt;
&lt;P&gt;The 012 is static defined data.&lt;/P&gt;
&lt;P&gt;The last twelve character data is another defined variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I try to create the variable without the wrapped double quotes, I'm getting invalid numeric data on the 'CSR+'. I assume it's due to the + sign?&lt;/P&gt;
&lt;P&gt;header='CSR+'+date1+date2+'012'+character_var;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 12:28:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-variable-from-multiple-sources/m-p/774866#M246306</guid>
      <dc:creator>G_I_Jeff</dc:creator>
      <dc:date>2021-10-18T12:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: Create variable from multiple sources</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-variable-from-multiple-sources/m-p/774868#M246307</link>
      <description>&lt;P&gt;You can't use + for character strings, because SAS thinks + is addition of numeric variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you want is the CATS function. See the example at &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lefunctionsref/n1e21rr6al5m2nn19r1fat5qxwrt.htm" target="_blank" rel="noopener"&gt;https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lefunctionsref/n1e21rr6al5m2nn19r1fat5qxwrt.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 12:34:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-variable-from-multiple-sources/m-p/774868#M246307</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-18T12:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: Create variable from multiple sources</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-variable-from-multiple-sources/m-p/774883#M246310</link>
      <description>&lt;P&gt;Good point, but how do I format the dates inside CATS and I still need double quotes around the entire built variable.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 13:35:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-variable-from-multiple-sources/m-p/774883#M246310</guid>
      <dc:creator>G_I_Jeff</dc:creator>
      <dc:date>2021-10-18T13:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: Create variable from multiple sources</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-variable-from-multiple-sources/m-p/774889#M246311</link>
      <description>&lt;P&gt;Use PUT with whatever date format that you need. We don't have a reproducible example to go off of, so it's difficult for us to get you on the right path. Here's one that I came up with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id $1. date :mmddyy10.;
datalines;
A 10/18/2021
;
run;

data want;
	set have;
	want = quote(cats(id, put(date, mmddyy10.)));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have produces this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Obs id date 
1 A 22571 

&lt;/PRE&gt;
&lt;P&gt;Want produces this:&lt;/P&gt;
&lt;PRE&gt;Obs id date want 
1 A 22571 "A10/18/2021" 
&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Oct 2021 14:14:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-variable-from-multiple-sources/m-p/774889#M246311</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2021-10-18T14:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: Create variable from multiple sources</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-variable-from-multiple-sources/m-p/774905#M246315</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19745"&gt;@G_I_Jeff&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Good point, but how do I format the dates inside CATS and I still need double quotes around the entire built variable.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No you do NOT need quotes around the entire variable, CATS produces only character strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You format dates the same way you would format any date at all, and as shown by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/281770"&gt;@maguiremq&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 14:55:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-variable-from-multiple-sources/m-p/774905#M246315</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-18T14:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: Create variable from multiple sources</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-variable-from-multiple-sources/m-p/774955#M246338</link>
      <description>&lt;P&gt;Okay, this is getting me pretty close. But I have 3 double quotes around the header variable and I'm just not seeing what I need to change:&lt;/P&gt;
&lt;PRE&gt;data _null_;                                                       
 file TAPE dsd;                                                    
 set user.nfctape;                                                 
 null='';                                                          
 rc='1';                                                           
 rc5='5';                                                          
 csr='CSR';                                                        
 sysid='SYSTEMID';                                                 
 acntcd='ACCOUNTCODE';                                             
 rate='ZRMM@@12';                                                  
 hlq1='DSNACCOUNTCODE1';                                           
 strt='Start_date';                                                
 stop='Stop_date';                                                 
 time='00:00:00';                                                  
 x=012;                                                            
 if size=0 then delete;                                            
 if account='' then account='nfcunknown';                          
 if account=. then account='nfcunknown';                           
 size=size*.001**3;                                                
 header=quote(cats(csr, put(start_date, yymmddn8.),                
        put(end_date, yymmddn8.), x, account));                    
 put header ident start_date end_date time time rc rc5 sysid system
     acntcd account strt start_date hlq1 hlq stop end_date         
     rc rate size;                                                 
run;                                                               &lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Oct 2021 17:43:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-variable-from-multiple-sources/m-p/774955#M246338</guid>
      <dc:creator>G_I_Jeff</dc:creator>
      <dc:date>2021-10-18T17:43:38Z</dc:date>
    </item>
  </channel>
</rss>

