<?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 length of variable in ODS OUTPUT in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/length-of-variable-in-ODS-OUTPUT/m-p/737152#M229776</link>
    <description>&lt;P&gt;I am saving the output from proc means in the OUTPUT dataset. my issue is with STD. In the output dataset, the column for std is created to be&amp;nbsp;&amp;amp;varname._StdDev.&lt;/P&gt;
&lt;P&gt;I am running this proc for so many variables and some of the names for the variables are so long that with the addition of _StdDev their length goes above 32.&lt;/P&gt;
&lt;P&gt;In the example below, the LEVEL portion of the var name is removed to fit the var name within 32 characters with the addition of _StdDev.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ods output Summary=Output; &lt;BR /&gt;proc means data=&amp;amp;dataset std MAXDEC=2; &lt;BR /&gt;var &amp;amp;varname;&lt;BR /&gt;run;&lt;BR /&gt;&lt;SPAN style="font-family: inherit;"&gt;The MEANS Procedure&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Means: Summary statistics" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c b header" scope="col"&gt;Analysis Variable : &lt;FONT color="#FF0000"&gt;parent_highest_education_&lt;FONT color="#339966"&gt;level&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r b header" scope="col"&gt;Std Dev&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;0.02&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P class="lia-align-left"&gt;proc print data=output; run;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;TABLE class="systitleandfootercontainer" border="0" summary="Page Layout" width="100%" frame="void" rules="none" cellspacing="1" cellpadding="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="c systemtitle"&gt;The SAS System&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.OUTPUT2" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col" width="24.8px" height="19px"&gt;&lt;FONT color="#000000"&gt;Obs&lt;/FONT&gt;&lt;/TH&gt;
&lt;TH class="r header" scope="col" width="224px" height="19px"&gt;&lt;FONT color="#FF0000"&gt;parent_highest_education_&lt;FONT color="#0000FF"&gt;_StdDev&lt;/FONT&gt;&lt;/FONT&gt;&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row" width="24.8px" height="29px"&gt;1&lt;/TH&gt;
&lt;TD width="224px" height="29px" class="r data"&gt;0.02&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-left"&gt;Now that I want to access this column which should have this format &amp;amp;varname._StdDev, it is not accessible. How may I access the variable that is cut to a level to be &amp;lt;=32 characters with the suffix StdDev?&lt;/P&gt;
&lt;P class="lia-align-left"&gt;I am using this new var name to RETAIN and change the order of columns in the OUTPUT dataset after merging that with some other columns.&lt;/P&gt;
&lt;P class="lia-align-left"&gt;Thanks&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Tue, 27 Apr 2021 03:40:56 GMT</pubDate>
    <dc:creator>Emma_at_SAS</dc:creator>
    <dc:date>2021-04-27T03:40:56Z</dc:date>
    <item>
      <title>length of variable in ODS OUTPUT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/length-of-variable-in-ODS-OUTPUT/m-p/737152#M229776</link>
      <description>&lt;P&gt;I am saving the output from proc means in the OUTPUT dataset. my issue is with STD. In the output dataset, the column for std is created to be&amp;nbsp;&amp;amp;varname._StdDev.&lt;/P&gt;
&lt;P&gt;I am running this proc for so many variables and some of the names for the variables are so long that with the addition of _StdDev their length goes above 32.&lt;/P&gt;
&lt;P&gt;In the example below, the LEVEL portion of the var name is removed to fit the var name within 32 characters with the addition of _StdDev.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ods output Summary=Output; &lt;BR /&gt;proc means data=&amp;amp;dataset std MAXDEC=2; &lt;BR /&gt;var &amp;amp;varname;&lt;BR /&gt;run;&lt;BR /&gt;&lt;SPAN style="font-family: inherit;"&gt;The MEANS Procedure&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Means: Summary statistics" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c b header" scope="col"&gt;Analysis Variable : &lt;FONT color="#FF0000"&gt;parent_highest_education_&lt;FONT color="#339966"&gt;level&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r b header" scope="col"&gt;Std Dev&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;0.02&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P class="lia-align-left"&gt;proc print data=output; run;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;TABLE class="systitleandfootercontainer" border="0" summary="Page Layout" width="100%" frame="void" rules="none" cellspacing="1" cellpadding="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="c systemtitle"&gt;The SAS System&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.OUTPUT2" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col" width="24.8px" height="19px"&gt;&lt;FONT color="#000000"&gt;Obs&lt;/FONT&gt;&lt;/TH&gt;
&lt;TH class="r header" scope="col" width="224px" height="19px"&gt;&lt;FONT color="#FF0000"&gt;parent_highest_education_&lt;FONT color="#0000FF"&gt;_StdDev&lt;/FONT&gt;&lt;/FONT&gt;&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row" width="24.8px" height="29px"&gt;1&lt;/TH&gt;
&lt;TD width="224px" height="29px" class="r data"&gt;0.02&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-left"&gt;Now that I want to access this column which should have this format &amp;amp;varname._StdDev, it is not accessible. How may I access the variable that is cut to a level to be &amp;lt;=32 characters with the suffix StdDev?&lt;/P&gt;
&lt;P class="lia-align-left"&gt;I am using this new var name to RETAIN and change the order of columns in the OUTPUT dataset after merging that with some other columns.&lt;/P&gt;
&lt;P class="lia-align-left"&gt;Thanks&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 27 Apr 2021 03:40:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/length-of-variable-in-ODS-OUTPUT/m-p/737152#M229776</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-04-27T03:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: length of variable in ODS OUTPUT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/length-of-variable-in-ODS-OUTPUT/m-p/737155#M229777</link>
      <description>&lt;P&gt;Why don't you refer to the dictionary table and look up the names of the variables in the OUTPUT data set?&lt;/P&gt;
&lt;P&gt;In the following code, the macro variable stdname will contain a variable name ending in "_StdDev".&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set sashelp.vcolumn;
  where memname='OUTPUT' and libname='WORK' and name like '%_StdDev';
  call symput('stdname',name);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Apr 2021 04:14:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/length-of-variable-in-ODS-OUTPUT/m-p/737155#M229777</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-04-27T04:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: length of variable in ODS OUTPUT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/length-of-variable-in-ODS-OUTPUT/m-p/737157#M229778</link>
      <description>&lt;P&gt;You could rename your original variables to take no more than 25 characters.&amp;nbsp; &amp;nbsp;Then adding "_STDDEV" would keep the resulting name at 32 or less.&amp;nbsp; This would ensure that you don't have a name which gets truncated for _STDDEV, but not for, say _MEAN.&amp;nbsp; And you wouldn't have to add code just to determine a variable name.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 04:35:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/length-of-variable-in-ODS-OUTPUT/m-p/737157#M229778</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-04-27T04:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: length of variable in ODS OUTPUT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/length-of-variable-in-ODS-OUTPUT/m-p/737162#M229779</link>
      <description>&lt;P&gt;Why not just use the real output dataset that the procedure produces?&lt;/P&gt;
&lt;P&gt;ODS OUTPUT is a last resort method to generate a dataset that you can use to get a dataset from a procedure that was originally only designed to produce a printed report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With the OUTPUT statement you can name the variables yourself.&lt;/P&gt;
&lt;P&gt;You can have them keep their original names by not specifying any new names.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=sashelp.class ;
  var _numeric_;
  output out=std std= ;
run;

proc print data=std; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;Obs    _TYPE_    _FREQ_      Age       Height     Weight

 1        0        19      1.49267    5.12708    22.7739
&lt;/PRE&gt;
&lt;P&gt;Or if you want just the statistics N, MIN, MAX, MEAN and STD then do not request any statistics in the OUTPUT statement.&amp;nbsp; You get a vertical dataset with each statistic on a different observation.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=sashelp.class ;
  var _numeric_;
  output out=want ;
run;

proc print data=want; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    _TYPE_    _FREQ_    _STAT_      Age       Height     Weight

 1        0        19       N        19.0000    19.0000     19.000
 2        0        19       MIN      11.0000    51.3000     50.500
 3        0        19       MAX      16.0000    72.0000    150.000
 4        0        19       MEAN     13.3158    62.3368    100.026
 5        0        19       STD       1.4927     5.1271     22.774
&lt;/PRE&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;</description>
      <pubDate>Tue, 27 Apr 2021 05:13:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/length-of-variable-in-ODS-OUTPUT/m-p/737162#M229779</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-27T05:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: length of variable in ODS OUTPUT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/length-of-variable-in-ODS-OUTPUT/m-p/737163#M229780</link>
      <description>&lt;P&gt;If you want more detail about what a variable holds you do not need to place all of that next into a variable name. SAS Variable labels can provide output usable in most places.&lt;/P&gt;
&lt;P&gt;So you could have a variable named "parent_hi_ed" or similar.&lt;/P&gt;
&lt;P&gt;Then attach a label&lt;/P&gt;
&lt;P&gt;label parent_hi_ed ="Parent's Highest Education Level";&lt;/P&gt;
&lt;P&gt;After proc mean you would have a variable parent_hi_ed_stddev and if needed in a report you attach a label like&lt;/P&gt;
&lt;P&gt;label parent_hi_ed_stddev ="Parent's Highest Education Level: Standard Deviation";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now for the obnoxious comment: If your coding for "education" does not have ratio type scale then this is next to useless.&lt;/P&gt;
&lt;P&gt;Example: coding 1 to 12 as "grades completed" or similar for first through 12th grade (high school) in typical US fashion is okay. But if 13 is "associates degree" then the 'interval' meaning between 12 and 13 is quite a bit different than between 11 and 12. This gets even less meaning full if you have "Bachelors degree" "Masters Degree" "PHD" and maybe some trade school. If the value is "years of education" then mean and stddev may mean something. But when a numeric rating scheme is only ordinal (low to high) where the intervals between each code do not mean exactly the same thing then these summary statistics are not likely appropriate. I won't even go into "equivalence" of things like GED vs High School Diploma or international school systems.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 05:09:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/length-of-variable-in-ODS-OUTPUT/m-p/737163#M229780</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-27T05:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: length of variable in ODS OUTPUT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/length-of-variable-in-ODS-OUTPUT/m-p/737382#M229873</link>
      <description>&lt;P&gt;Thank you, everyone, for your thoughts and suggestions. So many options! Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 19:06:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/length-of-variable-in-ODS-OUTPUT/m-p/737382#M229873</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-04-27T19:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: length of variable in ODS OUTPUT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/length-of-variable-in-ODS-OUTPUT/m-p/737385#M229874</link>
      <description>Thank you Tom. Your method is the easiest to use for my scenario. I am using the OUTPUT option but I have one question, if you may help:&lt;BR /&gt;&lt;BR /&gt; how may I choose the decimal point for the OUTPUT as the MAXDEC=2 in the PROC portion does not apply to the OUTPUT. Thanks!&lt;BR /&gt;&lt;BR /&gt;proc summary data=sashelp.class ;&lt;BR /&gt;  var _numeric_;&lt;BR /&gt;  output out=std std= ;&lt;BR /&gt;run;&lt;BR /&gt;proc print data=std; run;</description>
      <pubDate>Tue, 27 Apr 2021 19:13:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/length-of-variable-in-ODS-OUTPUT/m-p/737385#M229874</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-04-27T19:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: length of variable in ODS OUTPUT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/length-of-variable-in-ODS-OUTPUT/m-p/737391#M229876</link>
      <description>&lt;P&gt;To control how values print using a FORMAT statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=std; 
  format _numeric_ 5.2 ;
  format _type_ _freq_ ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Apr 2021 19:26:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/length-of-variable-in-ODS-OUTPUT/m-p/737391#M229876</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-27T19:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: length of variable in ODS OUTPUT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/length-of-variable-in-ODS-OUTPUT/m-p/737395#M229877</link>
      <description>Thank you, Tom!</description>
      <pubDate>Tue, 27 Apr 2021 19:30:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/length-of-variable-in-ODS-OUTPUT/m-p/737395#M229877</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-04-27T19:30:55Z</dc:date>
    </item>
  </channel>
</rss>

