<?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: Proc SQL inserting into fields cuts off variable length in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-inserting-into-fields-cuts-off-variable-length/m-p/669516#M200857</link>
    <description>&lt;P&gt;Thanks for the answer.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Why did you define the variable as having a length of 100 bytes but then attach a format to it that limits it to displaying just the first 30 bytes?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Mainly because I am a newbie having no clue what I am doing...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I changed the code to:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;PRE&gt;proc sql;
   create table blub.name.
       (ModelName char(10),
        &amp;amp;s. char(10),
		ModelName_&amp;amp;s. char(30),
		
        /*Coefficients*/
		parameter char length=100,
		DF num,
		Estimate num,
		StandardizedEst num,
		StdErr num,
		tValue num,
		Probt num

);
run;&lt;/PRE&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;However the error persists. What is even more astonishing is that even in the final table the length is set to 100.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am inserting multiple times with parameters of different length (Basically looping the regression over multiple "y"s). It seems that the length of the&amp;nbsp;first parameter is setting the tone for the ones following, i.e. xxxx_yy_wwwwwww_zzz is the first variable (from the first &lt;STRONG&gt;PARAMETERESTIMATES_DSN&lt;/STRONG&gt;)&amp;nbsp;and the second is xxxx_yy_wwwwwww_zzz_aaa (from the second &lt;STRONG&gt;PARAMETERESTIMATES_DSN &lt;/STRONG&gt;which I create seperately) which is cut short to xxxx_yy_wwwwwww_zzz.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the table containing the parameter information &lt;STRONG&gt;PARAMETERESTIMATES_DSN&lt;/STRONG&gt; I have the variable names stored that I want.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jul 2020 15:29:26 GMT</pubDate>
    <dc:creator>ab20</dc:creator>
    <dc:date>2020-07-15T15:29:26Z</dc:date>
    <item>
      <title>Proc SQL inserting into fields cuts off variable length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-inserting-into-fields-cuts-off-variable-length/m-p/669469#M200831</link>
      <description>&lt;P&gt;I am trying to insert values in a table that I create initially:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sql;
   create table blub.Name.
       (ModelName char(10),
               &amp;amp;s. char(10),
		MN_&amp;amp;s. char(30),
		
        /*Coefficients*/
		parameter char format=$30. length=100,
		DF num,
		Estimate num,
		StandardizedEst num,
		StdErr num,
		tValue num,
		Probt num
        );
run;&lt;/PRE&gt;&lt;P&gt;Then I run a regression analysis:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ods exclude all;
	proc glmselect data=blub.name2 
	               seed=1
				   ;
	   partition fraction(validate=0.2);
	   by &amp;amp;s.;



	model  &amp;amp;y. = 

	 &amp;amp;x.  	/ selection=none;


	output out=residual_dsn residual= r_dsn;
	ODS OUTPUT FitStatistics=FitStatistics_DSN;
	ODS OUTPUT ParameterEstimates=ParameterEstimates_DSN;


	run;
	*ods trace off; 
	ods exclude none;&lt;/PRE&gt;&lt;P&gt;In the table &lt;STRONG&gt;ParameterEstimates_DSN&lt;/STRONG&gt; are columns with same header as for the previously defined table, i.e. &lt;FONT face="Courier New" size="3"&gt;&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;s.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;parameter, DF, Estimate, StandardizedEst, StdErr, tValue, Probt.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I like to insert the values in my initial table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;	proc sql;
	   INSERT INTO blub.name (
	   				&amp;amp;s.,
					parameter,
					DF,
					Estimate,
					StandardizedEst,
					StdErr,
					tValue,
					Probt)
	   SELECT    	&amp;amp;s.,
				parameter,
				DF,
				Estimate,
				StandardizedEst,
				StdErr,
				tValue,
				Probt
	   FROM PARAMETERESTIMATES_DSN;
	run;&lt;/PRE&gt;&lt;P&gt;However, when doing so the length of columns defined in the initial step are ignored and the value for &lt;STRONG&gt;parameter&lt;/STRONG&gt; for example is cut off after a length of 20 even though I defined the length to be 100.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anybody know how to fix this issue?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 14:26:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-inserting-into-fields-cuts-off-variable-length/m-p/669469#M200831</guid>
      <dc:creator>ab20</dc:creator>
      <dc:date>2020-07-15T14:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL inserting into fields cuts off variable length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-inserting-into-fields-cuts-off-variable-length/m-p/669486#M200840</link>
      <description>&lt;P&gt;You put a format of $30. on your parameter column in the initial SQL. If you drop the "format=$30" from your CREATE TABLE statement, you will probably be able to see the whole parameter.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 14:46:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-inserting-into-fields-cuts-off-variable-length/m-p/669486#M200840</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2020-07-15T14:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL inserting into fields cuts off variable length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-inserting-into-fields-cuts-off-variable-length/m-p/669491#M200844</link>
      <description>&lt;P&gt;Why did you define the variable as having a length of 100 bytes but then attach a format to it that limits it to displaying just the first 30 bytes?&amp;nbsp; For that matter why did you attach a format to a character variable at all? Formats are special instructions for displaying the values. SAS does not need special instructions for displaying character strings.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 14:57:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-inserting-into-fields-cuts-off-variable-length/m-p/669491#M200844</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-15T14:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL inserting into fields cuts off variable length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-inserting-into-fields-cuts-off-variable-length/m-p/669512#M200855</link>
      <description>&lt;P&gt;Thanks for the answer. I changed the code to:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;PRE&gt;proc sql;
   create table blub.name.
       (ModelName char(10),
        &amp;amp;s. char(10),
		ModelName_&amp;amp;s. char(30),
		
        /*Coefficients*/
		parameter char length=100,
		DF num,
		Estimate num,
		StandardizedEst num,
		StdErr num,
		tValue num,
		Probt num

);
run;&lt;/PRE&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;However the error persists. What is even more astonishing is that even in the final table the length is set to 100.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am inserting multiple times with parameters of different length (Basically looping the regression over multiple "y"s). It seems that the length of the&amp;nbsp;first parameter is setting the tone for the ones following, i.e. xxxx_yy_wwwwwww_zzz is the first variable and the second is xxxx_yy_wwwwwww_zzz_aaa which is cut short to xxxx_yy_wwwwwww_zzz.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the table containing the parameter information &lt;STRONG&gt;PARAMETERESTIMATES_DSN&lt;/STRONG&gt; I have the variable names stored that I want.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 15:26:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-inserting-into-fields-cuts-off-variable-length/m-p/669512#M200855</guid>
      <dc:creator>ab20</dc:creator>
      <dc:date>2020-07-15T15:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL inserting into fields cuts off variable length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-inserting-into-fields-cuts-off-variable-length/m-p/669516#M200857</link>
      <description>&lt;P&gt;Thanks for the answer.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Why did you define the variable as having a length of 100 bytes but then attach a format to it that limits it to displaying just the first 30 bytes?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Mainly because I am a newbie having no clue what I am doing...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I changed the code to:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;PRE&gt;proc sql;
   create table blub.name.
       (ModelName char(10),
        &amp;amp;s. char(10),
		ModelName_&amp;amp;s. char(30),
		
        /*Coefficients*/
		parameter char length=100,
		DF num,
		Estimate num,
		StandardizedEst num,
		StdErr num,
		tValue num,
		Probt num

);
run;&lt;/PRE&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;However the error persists. What is even more astonishing is that even in the final table the length is set to 100.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am inserting multiple times with parameters of different length (Basically looping the regression over multiple "y"s). It seems that the length of the&amp;nbsp;first parameter is setting the tone for the ones following, i.e. xxxx_yy_wwwwwww_zzz is the first variable (from the first &lt;STRONG&gt;PARAMETERESTIMATES_DSN&lt;/STRONG&gt;)&amp;nbsp;and the second is xxxx_yy_wwwwwww_zzz_aaa (from the second &lt;STRONG&gt;PARAMETERESTIMATES_DSN &lt;/STRONG&gt;which I create seperately) which is cut short to xxxx_yy_wwwwwww_zzz.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the table containing the parameter information &lt;STRONG&gt;PARAMETERESTIMATES_DSN&lt;/STRONG&gt; I have the variable names stored that I want.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 15:29:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-inserting-into-fields-cuts-off-variable-length/m-p/669516#M200857</guid>
      <dc:creator>ab20</dc:creator>
      <dc:date>2020-07-15T15:29:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL inserting into fields cuts off variable length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-inserting-into-fields-cuts-off-variable-length/m-p/669669#M200916</link>
      <description>&lt;P&gt;Sounds like you are running some procedure multiple times and then are trying to append the results together?&amp;nbsp; What procedure are you using? Are you using an output dataset or did you have to rely on using ODS OUTPUT to get the data you need?&amp;nbsp; I think that in many cases ODS OUTPUT will not make consistent data structures.&amp;nbsp; It might even be attaching formats to some of the variables which might cause issues with the data appearing to be truncated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you might need to create a template dataset with large enough variables first.&amp;nbsp; Not sure why you would want to use SQL for that. Simple data step is fine.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data all;
  length
    ModelName $200
    paramenter $100
    df 8
    estimate 8
    StandarizedEst 8
     StdERR 8
    tvalue 8
    Probt 8
  ;
  stop;
run;    &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then after generating each result set use PROC APPEND to add the data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc xxxx out=PARAMETERESTIMATES_DSN  ; .... run;
proc append data=PARAMETERESTIMATES_DSN base=ALL force;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 19:31:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-inserting-into-fields-cuts-off-variable-length/m-p/669669#M200916</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-15T19:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL inserting into fields cuts off variable length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-inserting-into-fields-cuts-off-variable-length/m-p/670573#M201331</link>
      <description>Hi Tom. Thanks for your answer again. Unfortunately, it didn't work either. TO be able to continue I just shorted all the variables names to length 20...Not ideal but it worked...</description>
      <pubDate>Mon, 20 Jul 2020 06:51:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-inserting-into-fields-cuts-off-variable-length/m-p/670573#M201331</guid>
      <dc:creator>ab20</dc:creator>
      <dc:date>2020-07-20T06:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL inserting into fields cuts off variable length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-inserting-into-fields-cuts-off-variable-length/m-p/670580#M201335</link>
      <description>&lt;P&gt;Good that you've got a work-around. To avoid similar issues in the future it's eventually still worth for you to understand why things didn't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/311787"&gt;@ab20&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi Tom. Thanks for your answer again. Unfortunately, it didn't work either. TO be able to continue I just shorted all the variables names to length 20...Not ideal but it worked...&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Variable NAMES or VALUES?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Both variable names and variable lengths will be fixed when you create the table. It's nothing you can change later on without re-creating the table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it's variable lengths: The code you've posted creates the variable in the table with a length of 100bytes. If you then can't store a string that long then somehow in your process you must be either re-creating the table or you must be truncating the variable value somewhere before in an intermediary step.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you inspect your log are there any truncation warnings or the like?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2020 08:30:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-inserting-into-fields-cuts-off-variable-length/m-p/670580#M201335</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-07-20T08:30:51Z</dc:date>
    </item>
  </channel>
</rss>

