<?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 How to create variables in a new workset that reference multiple other worksets? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-a-new-workset-that-reference-multiple/m-p/327545#M271675</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a Grad student and I am working with administrative health data. I am working with 4 different databases that will allow me to locate a patient based on which database they are in. I am wanting to create a new data set and all it would have is all the patient IDs as observations and then the variables would be dates 1 through to 365 of a given year. The trick is that I want to write a program that will scan the 4 databases for each day variable and if a patient ID is found in that database on the given day a database specific flag will be returned to the set in the correct observation. Ideally this gives me a data set that I can see any time over a year a patient has used a health service from the 4 different data bases. Is this possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;More basic than that I am curious how I can transpose a given data set. As a hypothetical the data I am working with has patient's visits in chronological order as observations. Something like this:&lt;BR /&gt;&lt;BR /&gt;Patient ID &amp;nbsp; Visit Date&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1/25/2015&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5/26/2016&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6/14/2013&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 7/7/2010&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9/15/2015&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now what I want to do is create a data set where each observation is a patient and the variables are the different visit dates. Something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Patient ID &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt; 1/25/2015 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5/26/2016&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp; 6/14/2013&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp; 7/7/2010 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;9/15/2015&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is it possible to create a new data set that references the old one to sort of transpose the visit dates?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;Thank you for any input. It is much valued.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Jan 2017 21:22:39 GMT</pubDate>
    <dc:creator>jhathaway</dc:creator>
    <dc:date>2017-01-25T21:22:39Z</dc:date>
    <item>
      <title>How to create variables in a new workset that reference multiple other worksets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-a-new-workset-that-reference-multiple/m-p/327545#M271675</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a Grad student and I am working with administrative health data. I am working with 4 different databases that will allow me to locate a patient based on which database they are in. I am wanting to create a new data set and all it would have is all the patient IDs as observations and then the variables would be dates 1 through to 365 of a given year. The trick is that I want to write a program that will scan the 4 databases for each day variable and if a patient ID is found in that database on the given day a database specific flag will be returned to the set in the correct observation. Ideally this gives me a data set that I can see any time over a year a patient has used a health service from the 4 different data bases. Is this possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;More basic than that I am curious how I can transpose a given data set. As a hypothetical the data I am working with has patient's visits in chronological order as observations. Something like this:&lt;BR /&gt;&lt;BR /&gt;Patient ID &amp;nbsp; Visit Date&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1/25/2015&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5/26/2016&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6/14/2013&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 7/7/2010&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9/15/2015&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now what I want to do is create a data set where each observation is a patient and the variables are the different visit dates. Something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Patient ID &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt; 1/25/2015 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5/26/2016&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp; 6/14/2013&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp; 7/7/2010 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;9/15/2015&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is it possible to create a new data set that references the old one to sort of transpose the visit dates?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;Thank you for any input. It is much valued.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 21:22:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-a-new-workset-that-reference-multiple/m-p/327545#M271675</guid>
      <dc:creator>jhathaway</dc:creator>
      <dc:date>2017-01-25T21:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to create variables in a new workset that reference multiple other worksets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-a-new-workset-that-reference-multiple/m-p/327548#M271676</link>
      <description>&lt;P&gt;First thing, are those 4 other databases going to have records being updated constantly that you need to see?&lt;/P&gt;
&lt;P&gt;How will you read that data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may be able to create data views for each of those external databases. Basic code would look like:&lt;/P&gt;
&lt;P&gt;Data datafile1 / view=datafile1;&lt;/P&gt;
&lt;P&gt;&amp;lt;statements that would create the body of a data set&amp;gt;&lt;/P&gt;
&lt;P&gt;Infile and input or set. I have not done this with CONNECT to remote databases though.&lt;/P&gt;
&lt;P&gt;Then write code that aligns and merges those 4 views. The result would then refresh from the external source assuming everything goes well when ever it is used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without knowing what you will do with the result I can't make suggestions as to how to implemet more than that.&lt;/P&gt;
&lt;P&gt;I suspect that data in the form of&lt;/P&gt;
&lt;P&gt;Patientid Date DBSource &amp;lt;medical information fields&amp;gt; may be of more use.&lt;/P&gt;
&lt;P&gt;Make sure the Date variable(s) are SAS date values and with combined data then you query that data with things like: where date &amp;lt; '01Jul2016'd or between.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest that you seriously consider what you would do with that transposed data. Trying to match that to anything is going to be a nightmare.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 21:36:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-a-new-workset-that-reference-multiple/m-p/327548#M271676</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-25T21:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to create variables in a new workset that reference multiple other worksets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-a-new-workset-that-reference-multiple/m-p/327586#M271677</link>
      <description>&lt;P&gt;You could assemble your data using SQL:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table allData as
select "A" as db, patientId, visitDate from A
union all
select "B" as db, patientId, visitDate from B
union all
select "C" as db, patientId, visitDate from C
union all
select "D" as db, patientId, visitDate from D
order by patientId, visitDate, db;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Transposing might be useful for reporting but avoid it for any further data processing.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 23:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-variables-in-a-new-workset-that-reference-multiple/m-p/327586#M271677</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-01-25T23:32:50Z</dc:date>
    </item>
  </channel>
</rss>

