<?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: manipulate data query - transpose in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/manipulate-data-query-transpose/m-p/710735#M218846</link>
    <description>&lt;P&gt;I assume by "single customer view" that you mean you want all the data associated with a customer on a single row in a data set. Is that correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, what are you going to do with data in that form that you cannot do with it in the current form?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want a report that reads as such that is one thing, maybe something like:&lt;/P&gt;
&lt;PRE&gt;proc report data=a;
  columns cust_no year_contact,( branch_no visit_count);
  define cust_no / group;
  define year_contact /across "";
run;&lt;/PRE&gt;
&lt;P&gt;When you make the data set "wide", with multiple similar values then you have to create multiple variables.&lt;/P&gt;
&lt;P&gt;Such as 4 each year, branch and count variables for your given example. But unless every one of your customers have the exact same number of records you will have some customers with one of the variables populated and for longer term customers you could have 20 or more year variables and associated others. Which can make it hard to some things because you spend a lot of time parsing values out to find things like matching years across customers to get the same periods.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, please provide examples of the tasks you need to perform with the data that require a wide format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Quite often we see this question because the only training or experience new SAS users have comes from working with spreadsheets. SAS is not a spreadsheet. It has different abilities and for a vast majority of tasks the form of data that you have currently is more flexible.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Jan 2021 07:01:28 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-01-12T07:01:28Z</dc:date>
    <item>
      <title>manipulate data query - transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/manipulate-data-query-transpose/m-p/710727#M218843</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Hi All,&lt;BR /&gt;I have a query , which is the best way to transpose date .  &lt;BR /&gt;i would like get a single customer view . Can you advice .. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data a;
input visit_count cust_no year_contact branch_no;
datalines;
8 165670  2017 5308 
4 165670  2018 5308 
3 165670  2019 5308
2 165670  2020 5308 
;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 05:14:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/manipulate-data-query-transpose/m-p/710727#M218843</guid>
      <dc:creator>dennis_oz</dc:creator>
      <dc:date>2021-01-12T05:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: manipulate data query - transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/manipulate-data-query-transpose/m-p/710734#M218845</link>
      <description>&lt;P&gt;I'm not sure if this is what you want:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data a;&lt;BR /&gt;input visit_count cust_no year_contact branch_no;&lt;BR /&gt;datalines;&lt;BR /&gt;8 165670 2017 5308&lt;BR /&gt;4 165670 2018 5308&lt;BR /&gt;3 165670 2019 5308&lt;BR /&gt;2 165670 2020 5308&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc sort data=a;&lt;BR /&gt;by cust_no branch_no ;&lt;BR /&gt;run;&lt;BR /&gt;proc transpose data=a out=a_TR prefix=Year;&lt;BR /&gt;by cust_no branch_no ;&lt;BR /&gt;var visit_count;&lt;BR /&gt;id year_contact;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 07:00:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/manipulate-data-query-transpose/m-p/710734#M218845</guid>
      <dc:creator>Aku</dc:creator>
      <dc:date>2021-01-12T07:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: manipulate data query - transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/manipulate-data-query-transpose/m-p/710735#M218846</link>
      <description>&lt;P&gt;I assume by "single customer view" that you mean you want all the data associated with a customer on a single row in a data set. Is that correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, what are you going to do with data in that form that you cannot do with it in the current form?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want a report that reads as such that is one thing, maybe something like:&lt;/P&gt;
&lt;PRE&gt;proc report data=a;
  columns cust_no year_contact,( branch_no visit_count);
  define cust_no / group;
  define year_contact /across "";
run;&lt;/PRE&gt;
&lt;P&gt;When you make the data set "wide", with multiple similar values then you have to create multiple variables.&lt;/P&gt;
&lt;P&gt;Such as 4 each year, branch and count variables for your given example. But unless every one of your customers have the exact same number of records you will have some customers with one of the variables populated and for longer term customers you could have 20 or more year variables and associated others. Which can make it hard to some things because you spend a lot of time parsing values out to find things like matching years across customers to get the same periods.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, please provide examples of the tasks you need to perform with the data that require a wide format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Quite often we see this question because the only training or experience new SAS users have comes from working with spreadsheets. SAS is not a spreadsheet. It has different abilities and for a vast majority of tasks the form of data that you have currently is more flexible.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 07:01:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/manipulate-data-query-transpose/m-p/710735#M218846</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-12T07:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: manipulate data query - transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/manipulate-data-query-transpose/m-p/710780#M218860</link>
      <description>&lt;P&gt;what output do you like to see ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data a;
input visit_count cust_no year_contact branch_no;
datalines;
8 165670  2017 5308 
4 165670  2018 5308 
3 165670  2019 5308
2 165670  2020 5308 
;
run;

%let dsid=%sysfunc(open(a));
%let nobs=%sysfunc(attrn(&amp;amp;dsid,nlobs));
%let dsid=%sysfunc(close(&amp;amp;dsid));

proc summary data=a ;
by cust_no;
output out=want idgroup(out[&amp;amp;nobs] (visit_count year_contact branch_no)=);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jan 2021 11:27:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/manipulate-data-query-transpose/m-p/710780#M218860</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-01-12T11:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: manipulate data query - transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/manipulate-data-query-transpose/m-p/711541#M219211</link>
      <description>&lt;P&gt;This is an example of&amp;nbsp;&lt;CODE class=" language-sas"&gt;PROC TABULATE&lt;/CODE&gt;&amp;nbsp;which can summarize this data creating one "view" per customer.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC TABULATE DATA=WORK.A	FORMAT=4.	;
	
	VAR visit_count;
	CLASS year_contact 
	      branch_no    
	      cust_no      /	ORDER=UNFORMATTED MISSING;

	TABLE cust_no*visit_count*Sum=" ",
        branch_no,
        year_contact
	;

RUN;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Jan 2021 19:57:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/manipulate-data-query-transpose/m-p/711541#M219211</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2021-01-14T19:57:44Z</dc:date>
    </item>
  </channel>
</rss>

