<?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 Column header modification in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Column-header-modification/m-p/39467#M4725</link>
    <description>I am building a project in SAS EG 4.2 and I am wondering if it is possible to changes the name of the columns with out doing it manually.  I have 24 months of data each in its own column 12 months of previous data the current month and 11 months of future data.  I would like to be able to have the month and year as the column title and each month have them change automatically.  Here are the current column headers in EG.&lt;BR /&gt;
&lt;BR /&gt;
-12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 Current Month 1 2 3 4 5 6 7 8 9 10 11&lt;BR /&gt;
&lt;BR /&gt;
I would like the current month column title to be January 2010 (or current month) and then subtract or add from the current month and to get the appropriate month and year for each individual months relating to the current month.  I will be running this project each month so the current month will always be changing.  &lt;BR /&gt;
&lt;BR /&gt;
Any help would be appreciated</description>
    <pubDate>Tue, 12 Jan 2010 16:13:04 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-01-12T16:13:04Z</dc:date>
    <item>
      <title>Column header modification</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Column-header-modification/m-p/39467#M4725</link>
      <description>I am building a project in SAS EG 4.2 and I am wondering if it is possible to changes the name of the columns with out doing it manually.  I have 24 months of data each in its own column 12 months of previous data the current month and 11 months of future data.  I would like to be able to have the month and year as the column title and each month have them change automatically.  Here are the current column headers in EG.&lt;BR /&gt;
&lt;BR /&gt;
-12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 Current Month 1 2 3 4 5 6 7 8 9 10 11&lt;BR /&gt;
&lt;BR /&gt;
I would like the current month column title to be January 2010 (or current month) and then subtract or add from the current month and to get the appropriate month and year for each individual months relating to the current month.  I will be running this project each month so the current month will always be changing.  &lt;BR /&gt;
&lt;BR /&gt;
Any help would be appreciated</description>
      <pubDate>Tue, 12 Jan 2010 16:13:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Column-header-modification/m-p/39467#M4725</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-01-12T16:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Column header modification</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Column-header-modification/m-p/39468#M4726</link>
      <description>Here are some preliminary thoughts:&lt;BR /&gt;
&lt;BR /&gt;
1. Writing code would probably be the slickest solution. I'd have to play around to figure out what the best way to do this would be. Two techniques that come to mind are using dictionary.columns with PROC SQL or using a VNAME function within some DATA step code. Neither choice would be appropriate to give to a novice programmer.&lt;BR /&gt;
&lt;BR /&gt;
2. If you wanted to avoid writing code, you can do this in EG, but it's going to be a little messy. A stack columns task could get all the column names into a single column. You could then use a computed column expression in the query builder to manipulate the values (-12 to 11) and create valid names. Check out a PUT function and a MONYY format (I'm ommitting some details here!). Lastly you could use a split columns task on the data to spread things across the original 24 columns.&lt;BR /&gt;
&lt;BR /&gt;
If you could handle some of this when the data's being created, that would be even better. In other words, if there's already some SAS code that create a data set with -12 through 11, maybe you could tweak that code to give you what you want.</description>
      <pubDate>Wed, 13 Jan 2010 14:28:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Column-header-modification/m-p/39468#M4726</guid>
      <dc:creator>RichardH_sas</dc:creator>
      <dc:date>2010-01-13T14:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: Column header modification</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Column-header-modification/m-p/39469#M4727</link>
      <description>AirNav&lt;BR /&gt;
don't know if you're still interested, but since I've something similar, thought I might offer the code below.&lt;BR /&gt;
Assumptions: &lt;BR /&gt;
1 : the -12 through 11 are variable labels (to be replaced with "month year" dates)&lt;BR /&gt;
2 : for demonstration purposes, I assume your data is in a table named in macro variable &amp;amp;_data_1 &lt;BR /&gt;
3 : the header of that data set can be updated (a fairly high level of privilege)&lt;BR /&gt;
* create data with the required columns for testing ;[pre] %let _data_1 = your_data ;&lt;BR /&gt;
data &amp;amp;_data_1 ;   retain m1-m24 . ;&lt;BR /&gt;
  label  m1='-12'&lt;BR /&gt;
 m2='-11'&lt;BR /&gt;
 m3='-10'&lt;BR /&gt;
 m4='-9'&lt;BR /&gt;
 m5='-8'&lt;BR /&gt;
 m6='-7'&lt;BR /&gt;
 m7='-6'&lt;BR /&gt;
 m8='-5'&lt;BR /&gt;
 m9='-4'&lt;BR /&gt;
m10='-3'&lt;BR /&gt;
m11='-2'&lt;BR /&gt;
m12='-1'&lt;BR /&gt;
m13= 'Current Month'&lt;BR /&gt;
m14= '1'&lt;BR /&gt;
m15= '2'&lt;BR /&gt;
m16= '3'&lt;BR /&gt;
m17= '4'&lt;BR /&gt;
m18= '5'&lt;BR /&gt;
m19= '6'&lt;BR /&gt;
m20= '7'&lt;BR /&gt;
m21= '8'&lt;BR /&gt;
m22= '9'&lt;BR /&gt;
m23= '10'&lt;BR /&gt;
m24= '11'&lt;BR /&gt;
   ;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc contents data= &amp;amp;_data_1 noprint out= _data_ ;&lt;BR /&gt;
run ;&lt;BR /&gt;
data _null_ ;&lt;BR /&gt;
  if _n_ = 1 then do ;&lt;BR /&gt;
    set &amp;amp;syslast ;&lt;BR /&gt;
    call execute( 'proc datasets  nolist lib= '!! libname ) ;&lt;BR /&gt;
    call execute( '; modify ' !! memname  !! '; label ' ) ;&lt;BR /&gt;
  end ;&lt;BR /&gt;
  set &amp;amp;syslast end= finished ;&lt;BR /&gt;
  oLabN = input( label, ?? 12. ) ;&lt;BR /&gt;
  if label='Current Month' then lab= put( today(), nlDateYM. );&lt;BR /&gt;
  else if ( -12 LE oLabN LE 11 ) then&lt;BR /&gt;
      lab = put( intnx( 'month', today(), oLabN ), nlDateYM. );&lt;BR /&gt;
  call execute( name !! '= ' !! lab ) ;&lt;BR /&gt;
  if finished ;&lt;BR /&gt;
  call execute( '; run ; quit ;' ) ;&lt;BR /&gt;
run ;[/pre]

null</description>
      <pubDate>Mon, 25 Jan 2010 15:58:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Column-header-modification/m-p/39469#M4727</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-01-25T15:58:03Z</dc:date>
    </item>
  </channel>
</rss>

