<?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: Adding a custom header row in the Dataset (using SAS) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-custom-header-row-in-the-Dataset-using-SAS/m-p/780942#M248874</link>
    <description>&lt;P&gt;Hi Tom ! I do not want the data to look similar to my original spreadsheet. My end goal is to convert this data (the data without date headers) to TALL structure (like you have mentioned). To achive that I want headers on the date columns. I have made the TALL data structure using the "data with date headers" in it by using proc transpose&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC TRANSPOSE data=.....&lt;/P&gt;&lt;P&gt;by ID&lt;/P&gt;&lt;P&gt;VAR Date1-Date4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and doing some cleaning steps on the obtained data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that in the actual data (the data which doesn't have the date headers) there are no headers on dates, and I can not write actual dates in the 'VAR statement' as these dates might change in the next data. So, I need a method which can add these headers for me.&lt;/P&gt;</description>
    <pubDate>Thu, 18 Nov 2021 06:28:26 GMT</pubDate>
    <dc:creator>tumul</dc:creator>
    <dc:date>2021-11-18T06:28:26Z</dc:date>
    <item>
      <title>Adding a custom header row in the Dataset (using SAS)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-custom-header-row-in-the-Dataset-using-SAS/m-p/780754#M248790</link>
      <description>&lt;P&gt;Hi Guys ! Please help me figure this out&lt;/P&gt;&lt;P&gt;I have a payments dataset which stores the payments collected from different customers (ID column represent each customer) on different dates&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dataset which looks like this (in excel) :-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID 31-Mar-19 30-Apr-19 31-May-13 30-Jun-13&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1200&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1000&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; 2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2200&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; 3000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3030&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; 1500&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1600&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1650&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1600&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For customer ID "1", the amount collected on 31-May-19 was 1000, on 30-Apr-19 was 1200 and so on....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem with the dataset is that it does not have any CHARATCER headers for the payments.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to perform some tasks on this dataset in SAS, but for that I need the dataset to be in this form&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp;Date1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Date2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Date3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Date4&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 31-Mar-19&amp;nbsp; &amp;nbsp; 30-Apr-19&amp;nbsp; &amp;nbsp; 31-May-13&amp;nbsp; &amp;nbsp; &amp;nbsp;30-Jun-13&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; 1000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1200&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1000&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; 2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2200&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; 3000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3030&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; 1500&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1600&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1650&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1600&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So basically I need to shift the dates to a new row and add custom headers (Date1 to Date4) to the dataset. I have to add these headers in SAS as I am prohibited to do any changes in the excel data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me out !&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 15:05:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-a-custom-header-row-in-the-Dataset-using-SAS/m-p/780754#M248790</guid>
      <dc:creator>tumul</dc:creator>
      <dc:date>2021-11-17T15:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a custom header row in the Dataset (using SAS)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-custom-header-row-in-the-Dataset-using-SAS/m-p/780760#M248796</link>
      <description>&lt;P&gt;Note: You do not &lt;STRONG&gt;want&lt;/STRONG&gt; a "header row". Since a very common activity with data sets is sorting anything on a "row" would get shifted. Plus, SAS will not allow you to place character values into a numeric field.&lt;/P&gt;
&lt;P&gt;SAS has something called a LABEL that you associate with variables to provide more information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can assign labels 1) permanently when the set is created or using Proc Datasets on an existing data set or 2) provide Label statements in almost any procedure to override the default.&lt;/P&gt;
&lt;P&gt;Labels can be quite a bit longer , up to 256 characters, to provide more information in output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;data example;
   input ID     Date1         Date2            Date3            Date4;
   label
      Date1='31-Mar-19'    
      Date2='30-Apr-19'
      Date3='31-May-13'     
      Date4='30-Jun-13'
   ;
datalines;
1      1000           1200             1000              1000
2      2000            2000            2000               2200
3      3000            3000            3000               3030
4      1500            1600           1650               1600
;

proc print data=example label;
run;

/*providing labels at use*/
proc print data=example noobs label;
   label date1='Report date: 31 Mar 2019'
         date2='Sale date:  30 Apr 2019'
   ;
run;&lt;/PRE&gt;
&lt;P&gt;You can, in some procedures control some aspects of the display by adding special characters in telling those procedures to use the special character to "split" text rows:&lt;/P&gt;
&lt;PRE&gt;proc print data=example noobs label split='*';
   label date1='Report* date:* 31 Mar 2019'
         date2='Sale* date:*  30 Apr 2019'
   ;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Nov 2021 15:32:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-a-custom-header-row-in-the-Dataset-using-SAS/m-p/780760#M248796</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-11-17T15:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a custom header row in the Dataset (using SAS)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-custom-header-row-in-the-Dataset-using-SAS/m-p/780798#M248812</link>
      <description>&lt;P&gt;If I understand what is happening here is you have data in a spreadsheet where the DATE value is stored in the column header.&lt;/P&gt;
&lt;P&gt;To use such data for most things in SAS (or really any type of analysis) you probably will want to convert it to a "tall" structure where the DATE value is stored in a variable.&lt;/P&gt;
&lt;P&gt;So perhaps something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Obs    id    col         date    value

  1     1     1     31MAR2019     1000
  2     1     2     30APR2019     1200
  3     1     3     31MAY2013     1000
  4     1     4     30JUN2013     1000
  5     2     1     31MAR2019     2000
  6     2     2     30APR2019     2000
  7     2     3     31MAY2013     2000
  8     2     4     30JUN2013     2200
  9     3     1     31MAR2019     3000
 10     3     2     30APR2019     3000
 11     3     3     31MAY2013     3000
 12     3     4     30JUN2013     3030
 13     4     1     31MAR2019     1500
 14     4     2     30APR2019     1600
 15     4     3     31MAY2013     1650
 16     4     4     30JUN2013     1600
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you wanted to look at the data in a way that was similar to your original spreadsheet you could just make a report from the more useful tall structure.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report ;
  column id value,date ;
  define id / group;
  define date / across;
  define value / ' ';
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 456px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65844i5BAA8816445A13DE/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 17:45:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-a-custom-header-row-in-the-Dataset-using-SAS/m-p/780798#M248812</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-17T17:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a custom header row in the Dataset (using SAS)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-custom-header-row-in-the-Dataset-using-SAS/m-p/780942#M248874</link>
      <description>&lt;P&gt;Hi Tom ! I do not want the data to look similar to my original spreadsheet. My end goal is to convert this data (the data without date headers) to TALL structure (like you have mentioned). To achive that I want headers on the date columns. I have made the TALL data structure using the "data with date headers" in it by using proc transpose&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC TRANSPOSE data=.....&lt;/P&gt;&lt;P&gt;by ID&lt;/P&gt;&lt;P&gt;VAR Date1-Date4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and doing some cleaning steps on the obtained data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that in the actual data (the data which doesn't have the date headers) there are no headers on dates, and I can not write actual dates in the 'VAR statement' as these dates might change in the next data. So, I need a method which can add these headers for me.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2021 06:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-a-custom-header-row-in-the-Dataset-using-SAS/m-p/780942#M248874</guid>
      <dc:creator>tumul</dc:creator>
      <dc:date>2021-11-18T06:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a custom header row in the Dataset (using SAS)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-custom-header-row-in-the-Dataset-using-SAS/m-p/780950#M248878</link>
      <description>&lt;P&gt;Use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname=v7;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;before importing the excel-file, this will give you something like&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="header.jpg" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65861iD299D1203D51AE52/image-size/medium?v=v2&amp;amp;px=400" role="button" title="header.jpg" alt="header.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;In proc transpose you can then use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var _:;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to select all variables starting with an underscore.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2021 07:42:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-a-custom-header-row-in-the-Dataset-using-SAS/m-p/780950#M248878</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-11-18T07:42:40Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a custom header row in the Dataset (using SAS)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-custom-header-row-in-the-Dataset-using-SAS/m-p/780962#M248880</link>
      <description>&lt;P&gt;There is no need for an extra row to make TRANSPOSE work from your dataset, you just need to retrieve the names of the columns that have to be transposed:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID '31-Mar-19'n '30-Apr-19'n '31-May-13'n '30-Jun-13'n;
datalines;
1      1000         1200          1000          1000
2      2000          2000         2000           2200
3      3000          3000         3000           3030
4      1500          1600         1650           1600
;

proc sql noprint;
select nliteral(name) into :varlist separated by " "
from dictionary.columns
where libname = "WORK" and memname = "HAVE" and upcase(name) ne "ID";
quit;

proc transpose
  data=have
  out=long (rename=(col1=payment));
;
by id;
var &amp;amp;varlist.;
run;

data want;
set long;
date = input(_name_,date9.);
format date yymmdd10.;
drop _name_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If ID ends up as numeric in your data, I would also use the last data step to convert it to a character value; if it is already character after import, the transpose would even be simpler, as you could use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var _numeric_;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;without a specific list.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2021 08:27:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-a-custom-header-row-in-the-Dataset-using-SAS/m-p/780962#M248880</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-18T08:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a custom header row in the Dataset (using SAS)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-custom-header-row-in-the-Dataset-using-SAS/m-p/780977#M248891</link>
      <description>&lt;P&gt;Thank You everyone and especially&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;, This solves the issue !&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2021 09:31:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-a-custom-header-row-in-the-Dataset-using-SAS/m-p/780977#M248891</guid>
      <dc:creator>tumul</dc:creator>
      <dc:date>2021-11-18T09:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a custom header row in the Dataset (using SAS)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-custom-header-row-in-the-Dataset-using-SAS/m-p/781018#M248911</link>
      <description>&lt;P&gt;Do you really have a dataset with variable names that look like dates?&amp;nbsp; Or are those the variable labels?&lt;/P&gt;
&lt;P&gt;Anyway just use PROC TRANPOSE and then generate the DATE from the either the name or the label.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=tall ;
  by id;
run;

data want;
  set tall;
  date = input(_name_,date11.);
  format date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you really converted an EXCEL spreadsheet into a SAS dataset and the header row had actual date values in Excel then most likely the variable names have been converted into the number of days since 1900 (as Excel counts them).&amp;nbsp; So you might need to work a little harder to convert them into actual date values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date = input(compress(_name_,'_'),32.)+'30DEC1899'd ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Nov 2021 13:48:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-a-custom-header-row-in-the-Dataset-using-SAS/m-p/781018#M248911</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-18T13:48:27Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a custom header row in the Dataset (using SAS)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-custom-header-row-in-the-Dataset-using-SAS/m-p/781023#M248913</link>
      <description>The column headers were actually dates only. They were not strings, Yes ! those value were converted innto no_of_days since 1960 (after reading into SAS) and I had to transform them using offset 1900 (as this is what excel takes as reference date)&lt;BR /&gt;&lt;BR /&gt;thank you for you support !</description>
      <pubDate>Thu, 18 Nov 2021 14:12:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-a-custom-header-row-in-the-Dataset-using-SAS/m-p/781023#M248913</guid>
      <dc:creator>tumul</dc:creator>
      <dc:date>2021-11-18T14:12:44Z</dc:date>
    </item>
  </channel>
</rss>

