<?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: get day name in a transposed table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/get-day-name-in-a-transposed-table/m-p/765867#M242625</link>
    <description>&lt;P&gt;Little confused as to the exact output that you want. Notice that I created a new variable containing the name of the day of the week in your 'have' data set.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have ;
input ladate result employee $ ;
day_name = trim(left(put(ladate, downame.)));
informat ladate ddmmyy10. ;
format ladate ddmmyy10. ;
datalines ;
03/09/2021 1 robert
04/09/2021 5 robert
05/09/2021 8 robert
06/09/2021 9 robert
07/09/2021 23 robert
08/09/2021 56 robert
09/09/2021 15 robert
10/09/2021 48 robert
11/09/2021 99 robert
12/09/2021 23 robert
13/09/2021 45 robert
14/09/2021 48 robert
15/09/2021 1 robert
16/09/2021 5 robert
17/09/2021 8 robert
18/09/2021 9 robert
19/09/2021 23 robert
20/09/2021 56 robert
21/09/2021 15 robert
22/09/2021 48 robert
23/09/2021 99 robert
24/09/2021 23 robert
25/09/2021 45 robert
26/09/2021 48 robert
27/09/2021 11 robert
28/09/2021 12 robert
29/09/2021 13 robert
30/09/2021 16 robert
;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What I read:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=want (drop=_name_);
by employee ladate;
id day_name ;
var result ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs 	employee 	ladate 	Friday 	Saturday 	Sunday 	Monday 	Tuesday 	Wednesday 	Thursday
1 	robert 	03/09/2021 	1 	. 	. 	. 	. 	. 	.
2 	robert 	04/09/2021 	. 	5 	. 	. 	. 	. 	.
3 	robert 	05/09/2021 	. 	. 	8 	. 	. 	. 	.
4 	robert 	06/09/2021 	. 	. 	. 	9 	. 	. 	.
5 	robert 	07/09/2021 	. 	. 	. 	. 	23 	. 	.
6 	robert 	08/09/2021 	. 	. 	. 	. 	. 	56 	.
7 	robert 	09/09/2021 	. 	. 	. 	. 	. 	. 	15
8 	robert 	10/09/2021 	48 	. 	. 	. 	. 	. 	.
9 	robert 	11/09/2021 	. 	99 	. 	. 	. 	. 	.
10 	robert 	12/09/2021 	. 	. 	23 	. 	. 	. 	.
11 	robert 	13/09/2021 	. 	. 	. 	45 	. 	. 	.
12 	robert 	14/09/2021 	. 	. 	. 	. 	48 	. 	.
13 	robert 	15/09/2021 	. 	. 	. 	. 	. 	1 	.
14 	robert 	16/09/2021 	. 	. 	. 	. 	. 	. 	5
15 	robert 	17/09/2021 	8 	. 	. 	. 	. 	. 	.
16 	robert 	18/09/2021 	. 	9 	. 	. 	. 	. 	.
17 	robert 	19/09/2021 	. 	. 	23 	. 	. 	. 	.
18 	robert 	20/09/2021 	. 	. 	. 	56 	. 	. 	.
19 	robert 	21/09/2021 	. 	. 	. 	. 	15 	. 	.
20 	robert 	22/09/2021 	. 	. 	. 	. 	. 	48 	.
21 	robert 	23/09/2021 	. 	. 	. 	. 	. 	. 	99
22 	robert 	24/09/2021 	23 	. 	. 	. 	. 	. 	.
23 	robert 	25/09/2021 	. 	45 	. 	. 	. 	. 	.
24 	robert 	26/09/2021 	. 	. 	48 	. 	. 	. 	.
25 	robert 	27/09/2021 	. 	. 	. 	11 	. 	. 	.
26 	robert 	28/09/2021 	. 	. 	. 	. 	12 	. 	.
27 	robert 	29/09/2021 	. 	. 	. 	. 	. 	13 	.
28 	robert 	30/09/2021 	. 	. 	. 	. 	. 	. 	16&lt;/PRE&gt;
&lt;P&gt;What looks a little cleaner:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=want2 (drop=_name_);
by employee ladate day_name ;
var result ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs 	employee 	ladate 	day_name 	COL1
1 	robert 	03/09/2021 	Friday 	1
2 	robert 	04/09/2021 	Saturday 	5
3 	robert 	05/09/2021 	Sunday 	8
4 	robert 	06/09/2021 	Monday 	9
5 	robert 	07/09/2021 	Tuesday 	23
6 	robert 	08/09/2021 	Wednesday 	56
7 	robert 	09/09/2021 	Thursday 	15
8 	robert 	10/09/2021 	Friday 	48
9 	robert 	11/09/2021 	Saturday 	99
10 	robert 	12/09/2021 	Sunday 	23
11 	robert 	13/09/2021 	Monday 	45
12 	robert 	14/09/2021 	Tuesday 	48
13 	robert 	15/09/2021 	Wednesday 	1
14 	robert 	16/09/2021 	Thursday 	5
15 	robert 	17/09/2021 	Friday 	8
16 	robert 	18/09/2021 	Saturday 	9
17 	robert 	19/09/2021 	Sunday 	23
18 	robert 	20/09/2021 	Monday 	56
19 	robert 	21/09/2021 	Tuesday 	15
20 	robert 	22/09/2021 	Wednesday 	48
21 	robert 	23/09/2021 	Thursday 	99
22 	robert 	24/09/2021 	Friday 	23
23 	robert 	25/09/2021 	Saturday 	45
24 	robert 	26/09/2021 	Sunday 	48
25 	robert 	27/09/2021 	Monday 	11
26 	robert 	28/09/2021 	Tuesday 	12
27 	robert 	29/09/2021 	Wednesday 	13
28 	robert 	30/09/2021 	Thursday 	16&lt;/PRE&gt;</description>
    <pubDate>Fri, 03 Sep 2021 14:18:22 GMT</pubDate>
    <dc:creator>maguiremq</dc:creator>
    <dc:date>2021-09-03T14:18:22Z</dc:date>
    <item>
      <title>get day name in a transposed table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-day-name-in-a-transposed-table/m-p/765862#M242622</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;
&lt;P&gt;what I would like to obtain in this want table is the day name as first row.&lt;/P&gt;
&lt;P&gt;that is to say,&amp;nbsp;datas of&amp;nbsp;first row should be : friday, saturday, Sunday, monday…(vendredi, samedi, dimanche ...should be better)&lt;/P&gt;
&lt;P&gt;and second row should be 03/09/2021....&lt;/P&gt;
&lt;P&gt;by doing that, it will be easier to read when the table is exported into excel&lt;/P&gt;
&lt;P&gt;thanks&lt;/P&gt;
&lt;P&gt;nass&lt;/P&gt;
&lt;PRE&gt;Data have ;
input ladate result employee $ ;
informat ladate ddmmyy10. ;
format ladate ddmmyy10. ;
datalines ;
03/09/2021 1 robert
04/09/2021 5 robert
05/09/2021 8 robert
06/09/2021 9 robert
07/09/2021 23 robert
08/09/2021 56 robert
09/09/2021 15 robert
10/09/2021 48 robert
11/09/2021 99 robert
12/09/2021 23 robert
13/09/2021 45 robert
14/09/2021 48 robert
15/09/2021 1 robert
16/09/2021 5 robert
17/09/2021 8 robert
18/09/2021 9 robert
19/09/2021 23 robert
20/09/2021 56 robert
21/09/2021 15 robert
22/09/2021 48 robert
23/09/2021 99 robert
24/09/2021 23 robert
25/09/2021 45 robert
26/09/2021 48 robert
27/09/2021 11 robert
28/09/2021 12 robert
29/09/2021 13 robert
30/09/2021 16 robert
;
run ;

proc transpose data=have out=want (drop=_name_);
by employee ;
id ladate ;
var result ;
run ;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Sep 2021 13:28:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-day-name-in-a-transposed-table/m-p/765862#M242622</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2021-09-03T13:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: get day name in a transposed table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-day-name-in-a-transposed-table/m-p/765867#M242625</link>
      <description>&lt;P&gt;Little confused as to the exact output that you want. Notice that I created a new variable containing the name of the day of the week in your 'have' data set.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have ;
input ladate result employee $ ;
day_name = trim(left(put(ladate, downame.)));
informat ladate ddmmyy10. ;
format ladate ddmmyy10. ;
datalines ;
03/09/2021 1 robert
04/09/2021 5 robert
05/09/2021 8 robert
06/09/2021 9 robert
07/09/2021 23 robert
08/09/2021 56 robert
09/09/2021 15 robert
10/09/2021 48 robert
11/09/2021 99 robert
12/09/2021 23 robert
13/09/2021 45 robert
14/09/2021 48 robert
15/09/2021 1 robert
16/09/2021 5 robert
17/09/2021 8 robert
18/09/2021 9 robert
19/09/2021 23 robert
20/09/2021 56 robert
21/09/2021 15 robert
22/09/2021 48 robert
23/09/2021 99 robert
24/09/2021 23 robert
25/09/2021 45 robert
26/09/2021 48 robert
27/09/2021 11 robert
28/09/2021 12 robert
29/09/2021 13 robert
30/09/2021 16 robert
;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What I read:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=want (drop=_name_);
by employee ladate;
id day_name ;
var result ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs 	employee 	ladate 	Friday 	Saturday 	Sunday 	Monday 	Tuesday 	Wednesday 	Thursday
1 	robert 	03/09/2021 	1 	. 	. 	. 	. 	. 	.
2 	robert 	04/09/2021 	. 	5 	. 	. 	. 	. 	.
3 	robert 	05/09/2021 	. 	. 	8 	. 	. 	. 	.
4 	robert 	06/09/2021 	. 	. 	. 	9 	. 	. 	.
5 	robert 	07/09/2021 	. 	. 	. 	. 	23 	. 	.
6 	robert 	08/09/2021 	. 	. 	. 	. 	. 	56 	.
7 	robert 	09/09/2021 	. 	. 	. 	. 	. 	. 	15
8 	robert 	10/09/2021 	48 	. 	. 	. 	. 	. 	.
9 	robert 	11/09/2021 	. 	99 	. 	. 	. 	. 	.
10 	robert 	12/09/2021 	. 	. 	23 	. 	. 	. 	.
11 	robert 	13/09/2021 	. 	. 	. 	45 	. 	. 	.
12 	robert 	14/09/2021 	. 	. 	. 	. 	48 	. 	.
13 	robert 	15/09/2021 	. 	. 	. 	. 	. 	1 	.
14 	robert 	16/09/2021 	. 	. 	. 	. 	. 	. 	5
15 	robert 	17/09/2021 	8 	. 	. 	. 	. 	. 	.
16 	robert 	18/09/2021 	. 	9 	. 	. 	. 	. 	.
17 	robert 	19/09/2021 	. 	. 	23 	. 	. 	. 	.
18 	robert 	20/09/2021 	. 	. 	. 	56 	. 	. 	.
19 	robert 	21/09/2021 	. 	. 	. 	. 	15 	. 	.
20 	robert 	22/09/2021 	. 	. 	. 	. 	. 	48 	.
21 	robert 	23/09/2021 	. 	. 	. 	. 	. 	. 	99
22 	robert 	24/09/2021 	23 	. 	. 	. 	. 	. 	.
23 	robert 	25/09/2021 	. 	45 	. 	. 	. 	. 	.
24 	robert 	26/09/2021 	. 	. 	48 	. 	. 	. 	.
25 	robert 	27/09/2021 	. 	. 	. 	11 	. 	. 	.
26 	robert 	28/09/2021 	. 	. 	. 	. 	12 	. 	.
27 	robert 	29/09/2021 	. 	. 	. 	. 	. 	13 	.
28 	robert 	30/09/2021 	. 	. 	. 	. 	. 	. 	16&lt;/PRE&gt;
&lt;P&gt;What looks a little cleaner:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=want2 (drop=_name_);
by employee ladate day_name ;
var result ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs 	employee 	ladate 	day_name 	COL1
1 	robert 	03/09/2021 	Friday 	1
2 	robert 	04/09/2021 	Saturday 	5
3 	robert 	05/09/2021 	Sunday 	8
4 	robert 	06/09/2021 	Monday 	9
5 	robert 	07/09/2021 	Tuesday 	23
6 	robert 	08/09/2021 	Wednesday 	56
7 	robert 	09/09/2021 	Thursday 	15
8 	robert 	10/09/2021 	Friday 	48
9 	robert 	11/09/2021 	Saturday 	99
10 	robert 	12/09/2021 	Sunday 	23
11 	robert 	13/09/2021 	Monday 	45
12 	robert 	14/09/2021 	Tuesday 	48
13 	robert 	15/09/2021 	Wednesday 	1
14 	robert 	16/09/2021 	Thursday 	5
15 	robert 	17/09/2021 	Friday 	8
16 	robert 	18/09/2021 	Saturday 	9
17 	robert 	19/09/2021 	Sunday 	23
18 	robert 	20/09/2021 	Monday 	56
19 	robert 	21/09/2021 	Tuesday 	15
20 	robert 	22/09/2021 	Wednesday 	48
21 	robert 	23/09/2021 	Thursday 	99
22 	robert 	24/09/2021 	Friday 	23
23 	robert 	25/09/2021 	Saturday 	45
24 	robert 	26/09/2021 	Sunday 	48
25 	robert 	27/09/2021 	Monday 	11
26 	robert 	28/09/2021 	Tuesday 	12
27 	robert 	29/09/2021 	Wednesday 	13
28 	robert 	30/09/2021 	Thursday 	16&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Sep 2021 14:18:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-day-name-in-a-transposed-table/m-p/765867#M242625</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2021-09-03T14:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: get day name in a transposed table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-day-name-in-a-transposed-table/m-p/765868#M242626</link>
      <description>&lt;P&gt;...like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data next;
  set have;
  length weekday $9;
  select (weekday(ladate));
    when(1)weekday='Sunday';
    when(2)weekday='Monday';
    when(3)weekday='Tuesday';
    when(4)weekday='Wednesday';
    when(5)weekday='Thursday';
    when(6)weekday='Friday';
    when(7)weekday='Saturday';
    otherwise;
  end;
run;

proc transpose data=next out=want (drop=_name_);
  by employee ;
  id ladate ;
  var weekday ladate result;
run ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Sep 2021 14:27:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-day-name-in-a-transposed-table/m-p/765868#M242626</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-09-03T14:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: get day name in a transposed table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-day-name-in-a-transposed-table/m-p/765874#M242629</link>
      <description>&lt;P&gt;Hello kawakami&lt;/P&gt;
&lt;P&gt;many thanks for your respons il works well&lt;/P&gt;
&lt;P&gt;I just notice that when I have several employees (there, robert and&amp;nbsp;Alice).then I get many rows with weekday&lt;/P&gt;
&lt;P&gt;if I could get only one it could be great ! thanks&lt;/P&gt;
&lt;PRE&gt;Data have ;
input ladate result employee $ ;
day_name = trim(left(put(ladate, downame.)));
informat ladate ddmmyy10. ;
format ladate ddmmyy10. ;
datalines ;
03/09/2021 1 robert
04/09/2021 5 robert
05/09/2021 8 robert
06/09/2021 9 robert
07/09/2021 23 robert
08/09/2021 56 robert
09/09/2021 15 robert
10/09/2021 48 robert
11/09/2021 99 robert
12/09/2021 23 robert
13/09/2021 45 robert
14/09/2021 48 robert
15/09/2021 1 robert
16/09/2021 5 robert
17/09/2021 8 robert
18/09/2021 9 robert
19/09/2021 23 robert
20/09/2021 56 robert
21/09/2021 15 robert
22/09/2021 48 robert
23/09/2021 99 robert
24/09/2021 23 robert
25/09/2021 45 robert
26/09/2021 48 robert
27/09/2021 11 robert
28/09/2021 12 robert
29/09/2021 13 robert
30/09/2021 16 robert
03/09/2021 1 alice
04/09/2021 5 alice
05/09/2021 8 alice
06/09/2021 9 alice
07/09/2021 23 alice
08/09/2021 56 alice
09/09/2021 15 alice
10/09/2021 48 alice
11/09/2021 99 alice
12/09/2021 23 alice
13/09/2021 45 alice
14/09/2021 48 alice
15/09/2021 1 alice
16/09/2021 5 alice
17/09/2021 8 alice
18/09/2021 9 alice
19/09/2021 23 alice
20/09/2021 56 alice
21/09/2021 15 alice
22/09/2021 48 alice
23/09/2021 99 alice
24/09/2021 23 alice
25/09/2021 45 alice
26/09/2021 48 alice
27/09/2021 11 alice
28/09/2021 12 alice
29/09/2021 13 alice
30/09/2021 16 alice
;
run ;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Sep 2021 15:44:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-day-name-in-a-transposed-table/m-p/765874#M242629</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2021-09-03T15:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: get day name in a transposed table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-day-name-in-a-transposed-table/m-p/765881#M242633</link>
      <description>&lt;P&gt;I can't think of a smart way to do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=next out=next1(where=(_name_ ='result'));
  by employee ;
  id ladate ;
  var result weekday ladate ;
run ;
proc transpose data=next out=next2(where=(_name_^='result'));
  by employee ;
  id ladate ;
  var result weekday ladate ;
run ;
proc sort data=next2 nodupkey;
  by _name_;
run;
data next2;
  set next2;
  by _name_;
  employee='';
  if first._name_;
run;
data want;
  set next2 next1;
  drop _name_;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Sep 2021 16:14:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-day-name-in-a-transposed-table/m-p/765881#M242633</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-09-03T16:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: get day name in a transposed table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-day-name-in-a-transposed-table/m-p/765882#M242634</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/147725"&gt;@Nasser_DRMCP&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello kawakami&lt;/P&gt;
&lt;P&gt;many thanks for your respons il works well&lt;/P&gt;
&lt;P&gt;I just notice that when I have several employees (there, robert and&amp;nbsp;Alice).then I get many rows with weekday&lt;/P&gt;
&lt;P&gt;if I could get only one it could be great ! thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Provide an example of what your output should look like as well. Perhaps using a somewhat smaller input set will make that easier.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Sep 2021 16:15:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-day-name-in-a-transposed-table/m-p/765882#M242634</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-09-03T16:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: get day name in a transposed table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-day-name-in-a-transposed-table/m-p/766178#M242792</link>
      <description>&lt;P&gt;hello kawakami&lt;/P&gt;
&lt;P&gt;it works very well&lt;/P&gt;
&lt;P&gt;thanks a lot&lt;/P&gt;</description>
      <pubDate>Mon, 06 Sep 2021 08:52:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-day-name-in-a-transposed-table/m-p/766178#M242792</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2021-09-06T08:52:41Z</dc:date>
    </item>
  </channel>
</rss>

