<?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: Is there an easier way to make column headers not A B C and instead years like &amp;quot;1975&amp;quot; in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-there-an-easier-way-to-make-column-headers-not-A-B-C-and/m-p/535167#M146930</link>
    <description>I'm having an issue with the year column using your solution, they aren't the years for me anymore, they have changed to numbers such as "1488" onwards... any idea as to why? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
    <pubDate>Wed, 13 Feb 2019 12:32:45 GMT</pubDate>
    <dc:creator>JadeTheFirst</dc:creator>
    <dc:date>2019-02-13T12:32:45Z</dc:date>
    <item>
      <title>Is there an easier way to make column headers not A B C and instead years like "1975" from the data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-an-easier-way-to-make-column-headers-not-A-B-C-and/m-p/534295#M146606</link>
      <description>&lt;P&gt;SAS University Edition&lt;/P&gt;&lt;P&gt;So I'm trying to import some data into SAS from an excel file. (You can see the data in the xls file I've attached) SAS is unfortunately not using the&amp;nbsp;years like 1975,1976 etc as column headers which is what I want - it is using B C D E like excel sheets have by default.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used this code to get the data into SAS:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC IMPORT DATAFILE='/folders/myfolders/Historic Mortality data/Historic Mortality data/deathsbysingleyearofage.xls'
	DBMS=XLS
	OUT=WORK.DeathsByAgeWomenUK;
	GETNAMES=no;
	SHEET="Table 2";
	RANGE="MyRange2";
	NAMEROW=4;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;As previously mentioned - my data is meant to have years such as "1975" and "1976" as the column headers but it isn't, it's using "Age" yes but then jumping straight to using B,C,D etc. from excel.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was thinking of doing this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA DeathsByAgeWomenUKEDIT;
	SET WORK.DeathsByAgeWomenUK; 
	RENAME 	B="1974" C="1975" D="1976";
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But obviously for every single column, which would probably take too much time.&amp;nbsp;&lt;BR /&gt;I was thinking there's gotta be a way to do this easier - but I cannot find anything anywhere on how to do it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help with this would be hugely appreciated. Also feel free to ask any question if I haven't made this entirely clear &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Feb 2019 14:30:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-an-easier-way-to-make-column-headers-not-A-B-C-and/m-p/534295#M146606</guid>
      <dc:creator>JadeTheFirst</dc:creator>
      <dc:date>2019-02-10T14:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an easier way to make column headers not A B C and instead years like "1975"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-an-easier-way-to-make-column-headers-not-A-B-C-and/m-p/534296#M146607</link>
      <description>&lt;P&gt;The problem is that your file does not have valid variable names as its column headers.&amp;nbsp; You cannot name a variable 1974.&amp;nbsp; How would SAS (or anyone) interpret the code using such names?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;average = mean(1974,1975);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could try setting the options VALIDVARNAME to ANY.&lt;/P&gt;
&lt;P&gt;But then you would need to use name literals in your code to refer to these strangely named columns.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;average = mean("1974"n,'1975'n);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Feb 2019 14:40:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-an-easier-way-to-make-column-headers-not-A-B-C-and/m-p/534296#M146607</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-02-10T14:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an easier way to make column headers not A B C and instead years like "1975"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-an-easier-way-to-make-column-headers-not-A-B-C-and/m-p/534297#M146608</link>
      <description>&lt;P&gt;Treat the years as data, not variable names.&lt;/P&gt;
&lt;P&gt;Here is a method to get your table into a tall format where the value of YEAR is actual data instead of being trapped in metadata.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC IMPORT DATAFILE="&amp;amp;path/deathsbysingleyearofage.xls"
	DBMS=XLS
	OUT=test1;
	SHEET="Table 2";
	GETNAMES=no;
RUN;

proc transpose data=test1(obs=1) out=dates ;
  by age notsorted;
run;
proc transpose data=test1(firstobs=2) out=values ;
  by age notsorted;
run;

proc sql ;
  create table want as 
    select a.col1 as year
         , input(b.age,?3.) as age
         , b.age as age_label
         , b.col1 as deaths
    from dates a full join values b
    on a._name_ = b._name_ 
    order by 1,2
  ;
quit;

proc print data=want (obs=20); 
  where age in (0,1,104,105);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt; Obs    year    age    age_label       deaths

   1    1974      0    0                 5172
   2    1974      1    1                  383
 105    1974    104    104                 48
 106    1974    105    105+                33
 107    1975      0    0                 4798
 108    1975      1    1                  346
 211    1975    104    104                 40
 212    1975    105    105+                31
 213    1976      0    0                 4070
 214    1976      1    1                  298
 317    1976    104    104                 38
 318    1976    105    105+                49
 319    1977      0    0                 3933
 320    1977      1    1                  263
 423    1977    104    104                 37
 424    1977    105    105+                38
 425    1978      0    0                 3908
 426    1978      1    1                  287
 529    1978    104    104                 58
 530    1978    105    105+                47&lt;/PRE&gt;
&lt;P&gt;You can reproduce your source table as a report.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=want ;
 where age in (0,1,104,105) and year in (1974:1980);
 columns age age_label deaths,year ;
 define age / group noprint;
 define age_label / group ;
 define year / across ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 485px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27034i6A5B6644D25FFF1C/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Feb 2019 16:15:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-an-easier-way-to-make-column-headers-not-A-B-C-and/m-p/534297#M146608</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-02-10T16:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an easier way to make column headers not A B C and instead years like "1975"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-an-easier-way-to-make-column-headers-not-A-B-C-and/m-p/534311#M146612</link>
      <description>&lt;P&gt;If (1)you can save the workbook as an Excel workbook (i.e., .xlsx) and (2) variable names like _1984 and _1985 etc. will suffice, then you could get what you want with something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC IMPORT DATAFILE='/folders/myfolders/Historic Mortality data/Historic Mortality data/deathsbysingleyearofage.xlsx'
    DBMS=XLSx replace
    OUT=WORK.DeathsByAgeWomenUK;
  RANGE="MyRange2";
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course, if you use "options validvarname=any;", the above import would provide the variables as 1985, 1985, etc. but then, like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;said, you would have to refer to them as named literals.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Feb 2019 17:44:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-an-easier-way-to-make-column-headers-not-A-B-C-and/m-p/534311#M146612</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2019-02-10T17:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an easier way to make column headers not A B C and instead years like "1975"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-an-easier-way-to-make-column-headers-not-A-B-C-and/m-p/535167#M146930</link>
      <description>I'm having an issue with the year column using your solution, they aren't the years for me anymore, they have changed to numbers such as "1488" onwards... any idea as to why? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 13 Feb 2019 12:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-an-easier-way-to-make-column-headers-not-A-B-C-and/m-p/535167#M146930</guid>
      <dc:creator>JadeTheFirst</dc:creator>
      <dc:date>2019-02-13T12:32:45Z</dc:date>
    </item>
  </channel>
</rss>

