<?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: Transposing Multiple Variables into One Observation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395664#M95471</link>
    <description>&lt;P&gt;I might be tempted to see if this is exceptable;&lt;/P&gt;
&lt;PRE&gt;data have;
informat StudentID $5.   AcademicYear best5.    CumGPA best5.    EdLevel $10.     Major  $25.   AidAmount Dollar8.;
input StudentID    AcademicYear    CumGPA    EdLevel      Major    AidAmount;
datalines;
1000            1             3.20      Freshman     BasketWeaving      $1,800
1002            1             2.77      Freshman     SpaceAccounting    $3,600
1002            2             2.93      Sophomore    SpaceAccounting    $933
1002            3             3.11      Junior       SpaceAccounting    $0
1002            4             3.03      Senior       SpaceAccounting    $1,200
1003            3             2.46      Junior       Journalism         $645
1003            4             2.75      Senior       Journalism         $4,300
1004            1             3.30      Freshman     CryptoZoology      $10,500
1004            2             2.73      Sophomore    CryptoZoology      $4,000
1004            3             2.34      Sophomore    Biology            $1,175
;
run;

ods csv file='c:\path\junk.csv';
options missing=' ';
proc report data = have;
   columns studentid academicyear,( cumgpa edlevel major aidamount);
   define studentid / group;
   define academicyear / across;
run;
options missing='.';
ods csv close; 
   &lt;/PRE&gt;
&lt;P&gt;The csv file will have the data in one row per student though the actual data will start on row 3. This will let the analysts pick the variable names when they read the data and simplifies the creation. Since the number of columns will change and they have to adust the import unless you are supposed to provide a SAS data set (not explicitly stated). If you are sending them a data set I second &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;'s concerns about an analyst that can't reshape data or use it in the current form.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Sep 2017 17:38:22 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-09-13T17:38:22Z</dc:date>
    <item>
      <title>Transposing Multiple Variables into One Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395576#M95438</link>
      <description>&lt;P&gt;I have a number of different tables containing information on college students, such as their GPA at the end of each year, their major each year, amounts of different kinds of financial aid they took, cumulative credit hours, etc. Right now this exists in separate tables by topic (major and credits, financial aid, background info, etc.), with one row for each academic year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to transpose every variable in some of these tables so that instead of having anywhere from 1-8 rows per student in each table (depending on how long they were in school), we have a set of columns for each academic year 1 through 8.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, for example, the data I'm starting with looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;StudentID    AcademicYear    CumGPA    EdLevel      Major              AidAmount
1000            1             3.20      Freshman     BasketWeaving      $1,800&lt;BR /&gt;1002            1             2.77      Freshman     SpaceAccounting    $3,600&lt;BR /&gt;1002            2             2.93      Sophomore    SpaceAccounting    $933&lt;BR /&gt;1002            3             3.11      Junior       SpaceAccounting    $0&lt;BR /&gt;1002            4             3.03      Senior       SpaceAccounting    $1,200&lt;BR /&gt;1003            3             2.46      Junior       Journalism         $645&lt;BR /&gt;1003            4             2.75      Senior       Journalism         $4,300&lt;BR /&gt;1004            1             3.30      Freshman     CryptoZoology      $10,500&lt;BR /&gt;1004            2             2.73      Sophomore    CryptoZoology      $4,000&lt;BR /&gt;1004            3             2.34      Sophomore    Biology            $1,175&lt;BR /&gt;            &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want my output to look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;StudentID    CumGPA_1    EdLevel_1    Major_1          AidAmount_1    CumGPA_2    EdLevel_2    Major_2          AidAmount_2    CumGPA_3    EdLevel_3    Major_3          AidAmount_3    CumGPA_4    EdLevel_4    Major_4          AidAmount_4
1000          3.20        Freshman    BasketWeaving    $1,800&lt;BR /&gt;1002          2.77        Freshman    SpaceAccounting  $3,600          2.93       Sophomore    SpaceAccounting   $933           3.11       Junior       SpaceAccounting   $0             3.03        Senior      SpaceAccounting   $1,200&lt;BR /&gt;1003                                                                                                                            2.46       Junior       Journalism        $645           2.75        Senior      Journalism        $4,300&lt;BR /&gt;1004          3.30        Freshman    CryptoZoology    $10,500         2.73       Sophomore    CryptoZoology     $4,000         2.34       Sophomore    Biology           $1,175&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only way I can think of to do this with proc transpose involves rotating each of the above variables into new datasets individually (by StudentID with id AcademicYear), and then merging them all afterwards. I don't find that to be very practical given that I would have to do this for dozens of variables, and that we're expecting to receive additional data later in the year that will require everything to be done a second time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I presume there are ways to do this with arrays in a datastep, but the examples of array code I have found are usually making the opposite transformation (from wide to long), and don't explain the steps very welll. Would someone be able to help me with this, or point me to resources that outline the steps and functions that I would need to do this in a very concice way?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 15:18:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395576#M95438</guid>
      <dc:creator>cghost</dc:creator>
      <dc:date>2017-09-13T15:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Multiple Variables into One Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395584#M95442</link>
      <description>&lt;P&gt;First, what exactly will you do with the transposed data?&lt;/P&gt;
&lt;P&gt;The reason I ask is partially because of your statement:&lt;/P&gt;
&lt;P&gt;"&amp;nbsp;and that we're expecting to receive additional data later in the year that will require everything to be done a second time."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any code you write to handle 8 sets of variables will likely have multiple places where you have to then handle 9 (or 10 or whatever).&lt;/P&gt;
&lt;P&gt;And if you are doing this for the current year what about next year when you add yet more variables?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the purpose is to have a one-line per StudentId report then Proc Report or Tabulate will do that directly with the current data format and would not require any additional coding with added data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 15:27:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395584#M95442</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-13T15:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Multiple Variables into One Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395604#M95448</link>
      <description>&lt;P&gt;In my experience, this isn't a good storage mechanism for data. It makes it harder to work with in the long run.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a tutorial on how to do this via a data step. I'm not sure it's concise but again, this isn't something I'd recommend in the first place. Long data is easier to work with.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 16:13:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395604#M95448</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-13T16:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Multiple Variables into One Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395632#M95457</link>
      <description>The transposed data will be cleaned and then passed on to academic researchers for secondary use. The purpose of transposition is due to flat-file, single-observation/single-row datasets being the norm for us.&lt;BR /&gt;&lt;BR /&gt;The reason I want to avoid transposing each variable individually is that it sounds like it would create a great deal of additional code to revise if we get additional variables to add in later. I suppose I could build a macro that would loop transpose over a list of variables and merge the results, but I was hoping there would be a more straightforward solution.&lt;BR /&gt;&lt;BR /&gt;If Proc Report or Proc Tabulate can produce an output dataset that looks like the above, then I'd be interested to hear more.</description>
      <pubDate>Wed, 13 Sep 2017 16:53:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395632#M95457</guid>
      <dc:creator>cghost</dc:creator>
      <dc:date>2017-09-13T16:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Multiple Variables into One Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395634#M95458</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/131379"&gt;@cghost&lt;/a&gt; wrote:&lt;BR /&gt;The transposed data will be cleaned and then passed on to academic researchers for secondary use. The purpose of transposition is due to flat-file, single-observation/single-row datasets being the norm for us.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Talk to your researchers. This doesn't follow the tidy principles of data management and I HIGHLY suspect one of the first steps they do is normalize the data.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 16:55:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395634#M95458</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-13T16:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Multiple Variables into One Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395636#M95459</link>
      <description>&lt;P&gt;Unfortunately, the researchers are actually the people who asked me to do this.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 17:00:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395636#M95459</guid>
      <dc:creator>cghost</dc:creator>
      <dc:date>2017-09-13T17:00:48Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Multiple Variables into One Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395643#M95461</link>
      <description>&lt;P&gt;The dataset won't be growing (it's capped after 2017) but the number of variables included may.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't see the tutorial you mention. Am I missing a link somewhere?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 17:02:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395643#M95461</guid>
      <dc:creator>cghost</dc:creator>
      <dc:date>2017-09-13T17:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Multiple Variables into One Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395644#M95462</link>
      <description>&lt;P&gt;I'm screaming on the inside*, but I get where you're coming from.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it was me and I had to do this, I'd&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. create a macro that flips each variable. This would be a PROC TRANSPOSE essentially.&lt;/P&gt;
&lt;P&gt;2. Create a data set with each variable that needs to be included&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Call #1 based on data from #2 - Call Execute&lt;/P&gt;
&lt;P&gt;4. Because you have #2 you can also use that to drive the final merge so it's fully automated&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The next time you need to do this, since you likely provide data to researchers multiple times you would change #2 and the rest of the program would be the same. I'm not sure that's concise, but it would be dynamic and automated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*Rant: Researchers who can't handle data management are more likely to make assumptions to simplify the analysis and end up doing bad research - and I've seen too much of this that it frustrates me a lot. Yes, I'm generalizing and a lot are good once they get the data into SPSS...but a lot isn't. /Rant.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 17:04:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395644#M95462</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-13T17:04:01Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Multiple Variables into One Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395645#M95463</link>
      <description>&lt;A href="https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/how-to-reshape-data-long-to-wide-using-proc-transpose/&lt;/A&gt;</description>
      <pubDate>Wed, 13 Sep 2017 17:04:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395645#M95463</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-13T17:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Multiple Variables into One Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395647#M95464</link>
      <description>There's also this macro from some users on here that may do exactly what you want already:&lt;BR /&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings13/538-2013.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings13/538-2013.pdf&lt;/A&gt;</description>
      <pubDate>Wed, 13 Sep 2017 17:05:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395647#M95464</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-13T17:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Multiple Variables into One Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395664#M95471</link>
      <description>&lt;P&gt;I might be tempted to see if this is exceptable;&lt;/P&gt;
&lt;PRE&gt;data have;
informat StudentID $5.   AcademicYear best5.    CumGPA best5.    EdLevel $10.     Major  $25.   AidAmount Dollar8.;
input StudentID    AcademicYear    CumGPA    EdLevel      Major    AidAmount;
datalines;
1000            1             3.20      Freshman     BasketWeaving      $1,800
1002            1             2.77      Freshman     SpaceAccounting    $3,600
1002            2             2.93      Sophomore    SpaceAccounting    $933
1002            3             3.11      Junior       SpaceAccounting    $0
1002            4             3.03      Senior       SpaceAccounting    $1,200
1003            3             2.46      Junior       Journalism         $645
1003            4             2.75      Senior       Journalism         $4,300
1004            1             3.30      Freshman     CryptoZoology      $10,500
1004            2             2.73      Sophomore    CryptoZoology      $4,000
1004            3             2.34      Sophomore    Biology            $1,175
;
run;

ods csv file='c:\path\junk.csv';
options missing=' ';
proc report data = have;
   columns studentid academicyear,( cumgpa edlevel major aidamount);
   define studentid / group;
   define academicyear / across;
run;
options missing='.';
ods csv close; 
   &lt;/PRE&gt;
&lt;P&gt;The csv file will have the data in one row per student though the actual data will start on row 3. This will let the analysts pick the variable names when they read the data and simplifies the creation. Since the number of columns will change and they have to adust the import unless you are supposed to provide a SAS data set (not explicitly stated). If you are sending them a data set I second &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;'s concerns about an analyst that can't reshape data or use it in the current form.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 17:38:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/395664#M95471</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-13T17:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Multiple Variables into One Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/396363#M95686</link>
      <description>&lt;PRE&gt;
Try MERGE skill.



data have;
input StudentID    AcademicYear    CumGPA   ( EdLevel      Major   ) (: $20.)          AidAmount : comma32.;
cards;
1000            1             3.20      Freshman     BasketWeaving      $1,800
1002            1             2.77      Freshman     SpaceAccounting    $3,600
1002            2             2.93      Sophomore    SpaceAccounting    $933
1002            3             3.11      Junior       SpaceAccounting    $0
1002            4             3.03      Senior       SpaceAccounting    $1,200
1003            3             2.46      Junior       Journalism         $645
1003            4             2.75      Senior       Journalism         $4,300
1004            1             3.30      Freshman     CryptoZoology      $10,500
1004            2             2.73      Sophomore    CryptoZoology      $4,000
1004            3             2.34      Sophomore    Biology            $1,175
;
run;
proc sql;
create table x as
select distinct AcademicYear from have;
quit;

data _null_;
 set x end=last;
 if _n_=1 then call execute('data want;merge ');
 call execute(catt('have(where=(AcademicYear=',AcademicYear,')
rename=(CumGPA=CumGPA',AcademicYear
,' EdLevel=EdLevel',AcademicYear
,' Major=Major',AcademicYear,' AidAmount=AidAmount',AcademicYear,' ))'));
if last then call execute(';by StudentID;drop AcademicYear;run;');
run;
            



&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Sep 2017 14:43:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/396363#M95686</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-09-15T14:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Multiple Variables into One Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/396440#M95705</link>
      <description>&lt;P&gt;I see a number of choices in your problem statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My perspective is show in&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.analytics.ncsu.edu/sesug/2013/CC-04.pdf" target="_self"&gt;Database Vocabulary: Is Your Data Set a Dimension (LookUp) Table, a. Fact Table or a Report? &lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My commentary has two parts: example, and critique of your problem&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* example of database transaction table, snapshots: periodic(monthly) and accumulating&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. transaction table, of credit card purchases&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA library.transactions_data_structure;
     attrib id       length = 8&lt;BR /&gt;            datetime length = 8
            vendor   length = $16
            amount   length = 8;
stop;

DATA transactions_2017;
          if 0 then set library.transactions_data_structure;
infile datalines;
datalines;
...
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;2. summary to grain = monthly&lt;/P&gt;&lt;P&gt;macro or %include?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC summary data = transactions_&amp;amp;year
                   (where =(&amp;amp;date_start &amp;lt;=datetime &amp;lt;=&amp;amp;date_end));
*out =library.snapshot_accum_&amp;amp;year._month&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This paper&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sascommunity.org/wiki/Macro_Loops_with_Dates" target="_self"&gt;Macro_Loops_with_Dates&lt;/A&gt; has code to fetch the date_* information into macro variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. accumulating snapshot, which I suspect is kind of what you want.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA library.snapshot_accum_data_structure;
   if 0 then set library.transaction_data_structure(keep = id);
    attrib sum_01 length = 8&lt;BR /&gt;           ...&lt;BR /&gt;           sum_12 length = 8;&lt;BR /&gt;stop;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA library.snapshot_accum_&amp;amp;year;
if 0 then set library.library.snapshot_accum_data_structure;
update library.snapshot_accum_&amp;amp;year
      library.snapshot_accum_&amp;amp;year._&amp;amp;month;
by id;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;summary: database theory is always about data structure and what it is used for&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* transaction history is only appended to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* snapshot-periodic (grain in(daily, weekly, monthly, quarter, annual))&lt;/P&gt;&lt;P&gt;is a summation of transaction history, between two date(-times)&lt;/P&gt;&lt;P&gt;run once after grain is closed&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* snapshot-accumulating for the annual budget summary shown above&lt;/P&gt;&lt;P&gt;is run after the periodic-snapshot is complete&lt;/P&gt;&lt;P&gt;may be, probably is, in same program.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;** my commentary on your problem.&lt;/P&gt;&lt;P&gt;your description kinda/sorta fits the model of snapshot-accumulating.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The choices I see for you are:&lt;/P&gt;&lt;P&gt;* I suggest two fields year and AcademicYear&lt;/P&gt;&lt;P&gt;I know you have several examples of people who were sophomores for many years.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* naming conventions of variables:&lt;/P&gt;&lt;P&gt;cum_GPA_year_2016&lt;/P&gt;&lt;P&gt;or cum_GPA_year_1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* text fields EdLevel and Major ought to be reduced to integers&lt;/P&gt;&lt;P&gt;the last thing you want to be doing is editing or worse, parsing text, for information&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;last advice:&lt;/P&gt;&lt;P&gt;design the data structure of your last report first&lt;/P&gt;&lt;P&gt;and move back up the line, with the example theory shown above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hth&lt;/P&gt;&lt;P&gt;Ron Fehd&amp;nbsp; recipe maven&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 17:51:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/396440#M95705</guid>
      <dc:creator>Ron_MacroMaven</dc:creator>
      <dc:date>2017-09-15T17:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Multiple Variables into One Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/396467#M95721</link>
      <description>&lt;P&gt;Sorry to be so late to the party, but I just noticed&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;'s post mentioning the macro that a group of us wrote in 2013.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just updated that macro this afternoon. The latest version can be found at:&amp;nbsp;&lt;A href="http://www.sascommunity.org/wiki/A_Better_Way_to_Flip_(Transpose)_a_SAS_Dataset" target="_blank"&gt;http://www.sascommunity.org/wiki/A_Better_Way_to_Flip_(Transpose)_a_SAS_Dataset&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I strongly recommend downloading the file from that site because trying to copy code from a pdf file is fraught with all kinds of problems.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code runs 50 times or more faster than PROC TRANSPOSE, requires one to type a lot less, and does a lot of things that PROC TRANSPOSE doesn't do. It was designed, specifically, to make a wide file wider. What it does, additionally, is create transposed variables that maintain the original variables' types, lengths, formats and labels.&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>Fri, 15 Sep 2017 20:14:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/396467#M95721</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-09-15T20:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Multiple Variables into One Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/605639#M175793</link>
      <description>&lt;P&gt;Try PROC TRANSPOSE for twice.&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc transpose data=aa out=bb;&lt;/P&gt;&lt;P&gt;by studentid academicyear;&lt;/P&gt;&lt;P&gt;var cumgpa edlevel major aidamout;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc transpose data=bb out=cc(drop=_name_);&lt;/P&gt;&lt;P&gt;by studentid;&lt;/P&gt;&lt;P&gt;var col1;&lt;/P&gt;&lt;P&gt;id academicyear _name_;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 07:46:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Multiple-Variables-into-One-Observation/m-p/605639#M175793</guid>
      <dc:creator>deng47</dc:creator>
      <dc:date>2019-11-20T07:46:33Z</dc:date>
    </item>
  </channel>
</rss>

