<?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: Length of variable and merge in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448338#M69578</link>
    <description>&lt;P&gt;You can replace the last 5 steps with :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;&lt;BR /&gt;create table parmEst as
select compbl(coalesce(a.parameter,b.parameter)) as parameter,
a.estimate as estimate1,
b.estimate as estimate2
from parmest_1 as a full join parmest_2 as b
on compbl(a.parameter) = compbl(b.parameter);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 23 Mar 2018 21:46:18 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2018-03-23T21:46:18Z</dc:date>
    <item>
      <title>Length of variable and merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448325#M69572</link>
      <description>&lt;PRE&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dear SAS-users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running several regressions as above. I am creating 'parmest' dataset&amp;nbsp;to save the results. My problem is that the&amp;nbsp;length of the variable "parameter" in parmest_1 and parmest_2 are different due to the max. length of the parameter. One has 15 characters the other one has 19. This means that the name on the categorical variable "year" will be different also: "year 2010"&amp;nbsp;vs 'year&amp;nbsp;&amp;nbsp;&amp;nbsp; 2010'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I merge the two datasets ( parmest_1 and parmest_2), SAS doesn't recognize them as the same name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Somehow I need to set the length of the variable parameter even before it is created. How would I go about doing that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data claims_1;
input client year cost contract;
datalines;
18 2011 589.92 10.2
19 2010 1629.8 11.5
20 2011 1813.29 2.3
21 2012 412.06 3.2
22 2012 219.82 0.4
23 2010 3669.98 5.9
24 2012 4879.63 6.8

;
run;

/*model 1*/
proc glm data=claims_1;
class year (ref='2010' );
model cost=year/ solution;
ods output ParameterEstimates=work.parmest_1;
run;

/* model 2*/
proc glm data=claims_1;
class year (ref='2010' );
model cost=year|contract/ solution;
ods output ParameterEstimates=work.parmest_2;
run;

data work.parmest_1;
set work.parmest_1;
keep Parameter Estimate;
rename Estimate=Estimate1;
run;

data work.parmest_2;
set work.parmest_2;
keep Parameter Estimate;
rename Estimate=Estimate2;
run;


proc sort data=parmest_1 out=parmest_1;
by Parameter;

run;

proc sort data=parmest_2 out=parmest_2;
by Parameter;
run;

DATA work.parmest;
length parameter $19;
MERGE parmest_1 parmest_2;
BY Parameter;
RUN;


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Mar 2018 21:17:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448325#M69572</guid>
      <dc:creator>GKati</dc:creator>
      <dc:date>2018-03-23T21:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Length of variable and merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448329#M69573</link>
      <description>&lt;P&gt;I don't get that note, with your LENGTH statement in, though 19 is a bit short. I would set it to at least 32*2+1 for 2 variables Plus an interaction symbol.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 20:54:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448329#M69573</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-23T20:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: Length of variable and merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448331#M69574</link>
      <description>I edited my post. I hope this makes it more clear.</description>
      <pubDate>Fri, 23 Mar 2018 21:13:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448331#M69574</guid>
      <dc:creator>GKati</dc:creator>
      <dc:date>2018-03-23T21:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: Length of variable and merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448335#M69575</link>
      <description>It doesn't matter how I specify the length of the variable 'parameter', I get the same problem. Or am I misunderstanding your comment?</description>
      <pubDate>Fri, 23 Mar 2018 21:27:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448335#M69575</guid>
      <dc:creator>GKati</dc:creator>
      <dc:date>2018-03-23T21:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: Length of variable and merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448336#M69576</link>
      <description>&lt;P&gt;Fix the length before the step that does the merge. Should be easy since you already have data steps that are modifying the datasets.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.parmest_1;
length Parameter $50 ;
set work.parmest_1;
keep Parameter Estimate;
rename Estimate=Estimate1;
run;

data work.parmest_2;
length Parameter $50 ;
set work.parmest_2;
keep Parameter Estimate;
rename Estimate=Estimate2;
run;

...

DATA work.parmest;
MERGE work.parmest_1 work.parmest_2;
BY Parameter;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Mar 2018 21:32:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448336#M69576</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-23T21:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: Length of variable and merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448337#M69577</link>
      <description>&lt;P&gt;Thanks for your post Tom! Unfortunately that doesn't work. The name is created by then..."year 2010" vs 'year&amp;nbsp; &amp;nbsp; 2010'.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My gut feeling tells me I&amp;nbsp; need to do something before the regression is run.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 21:36:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448337#M69577</guid>
      <dc:creator>GKati</dc:creator>
      <dc:date>2018-03-23T21:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: Length of variable and merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448338#M69578</link>
      <description>&lt;P&gt;You can replace the last 5 steps with :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;&lt;BR /&gt;create table parmEst as
select compbl(coalesce(a.parameter,b.parameter)) as parameter,
a.estimate as estimate1,
b.estimate as estimate2
from parmest_1 as a full join parmest_2 as b
on compbl(a.parameter) = compbl(b.parameter);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Mar 2018 21:46:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448338#M69578</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-03-23T21:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: Length of variable and merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448339#M69579</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/123185"&gt;@GKati&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your post Tom! Unfortunately that doesn't work. The name is created by then..."year 2010" vs 'year&amp;nbsp; &amp;nbsp; 2010'.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My gut feeling tells me I&amp;nbsp; need to do something before the regression is run.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Unfortunately I think the only way to control the ODS tables are using templates which is a pain and overkill.&amp;nbsp;&lt;BR /&gt;My other thought was to get the data using an OUTPUT/OUT option, since you're only working with the estimates but I didn't see a way to do that which makes me think I've been staring at too much computers this week because it should be there somewhere.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 21:41:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448339#M69579</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-23T21:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: Length of variable and merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448342#M69580</link>
      <description>This didn't produce any output for me and I'm not sure which part of it would solve my problem.</description>
      <pubDate>Fri, 23 Mar 2018 21:46:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448342#M69580</guid>
      <dc:creator>GKati</dc:creator>
      <dc:date>2018-03-23T21:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: Length of variable and merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448343#M69581</link>
      <description>Unfortunately, i do need things other than parameters in my full code. I also merge in Number of observations, and goodness of fit statistics.</description>
      <pubDate>Fri, 23 Mar 2018 21:47:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448343#M69581</guid>
      <dc:creator>GKati</dc:creator>
      <dc:date>2018-03-23T21:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: Length of variable and merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448345#M69582</link>
      <description>&lt;P&gt;The output was in the Output window, I just edited the query to create a table instead. Please try it again.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 21:49:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448345#M69582</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-03-23T21:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: Length of variable and merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448347#M69583</link>
      <description>Yes, this works! Thanks</description>
      <pubDate>Fri, 23 Mar 2018 21:54:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Length-of-variable-and-merge/m-p/448347#M69583</guid>
      <dc:creator>GKati</dc:creator>
      <dc:date>2018-03-23T21:54:19Z</dc:date>
    </item>
  </channel>
</rss>

