<?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: Assigning values based on another variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917494#M41057</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/333045"&gt;@Ihsan-Mahdi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you so much. I will try this and let you know. Really appreciate it!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Just as a feedback:&lt;/P&gt;
&lt;P&gt;I've spent more than half of my time for converting your table with sample data to a SAS data step have that creates the data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to help us help you then going forward please provide sample data via SAS code that creates the data same as I've done it in my data have step.&lt;/P&gt;</description>
    <pubDate>Thu, 22 Feb 2024 23:54:18 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2024-02-22T23:54:18Z</dc:date>
    <item>
      <title>Assigning values based on another variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917480#M41049</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a set with hospital IDs, names, and addresses. In the same set the same hospital could be the place for patient admission, patient referral (patient sent to another hospital), or patient reception (patient came from another hospital). The address is assigned only to the admission hospital.&lt;/P&gt;
&lt;P&gt;Is there a quick way/code to create referring hospital and receiving hospital address variables&amp;nbsp; using the hospital ID and Address fields?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 22:31:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917480#M41049</guid>
      <dc:creator>Ihsan-Mahdi</dc:creator>
      <dc:date>2024-02-22T22:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning values based on another variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917484#M41050</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/333045"&gt;@Ihsan-Mahdi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a quick way/code to create referring hospital and receiving hospital address variables&amp;nbsp; using the hospital ID and Address fields?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think the answer is YES, but without seeing example data and example desired output, I don't think I can write such code. If the information is confidential, you can make up hospital names and addresses, as long as the data set and desired output illustrates the actual problem.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 22:57:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917484#M41050</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-02-22T22:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning values based on another variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917485#M41051</link>
      <description>&lt;P&gt;If you've got in your data the hospital IDs for patient admission, patient referral and patient reception then it's a simple lookup.&lt;/P&gt;
&lt;P&gt;To provide code we would need sample data that's representative for your real data (please share via SAS data step code that creates such data).&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 23:09:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917485#M41051</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-02-22T23:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning values based on another variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917487#M41052</link>
      <description>&lt;P&gt;Thanks for offering to help! I think the tables below best describe&amp;nbsp;(to me at least &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;) what I have and what I want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="817"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD colspan="6" width="817" class="lia-align-center"&gt;HAVE&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Obs&lt;/TD&gt;
&lt;TD&gt;Hospital ID&lt;/TD&gt;
&lt;TD&gt;Hospital Name (where patient currently is)&lt;/TD&gt;
&lt;TD&gt;Address&lt;/TD&gt;
&lt;TD&gt;Referring Hx ID&lt;/TD&gt;
&lt;TD&gt;Receiving Hx ID&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;310 S X Ave&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;99&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;31 Y Ave&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;102&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;45 D Ave&lt;/TD&gt;
&lt;TD&gt;5&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;37&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;63 E Ave&lt;/TD&gt;
&lt;TD&gt;6&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="978"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD colspan="8" width="978" class="lia-align-center"&gt;WANT&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Obs&lt;/TD&gt;
&lt;TD&gt;Hospital ID&lt;/TD&gt;
&lt;TD&gt;Hospital Name (where patient currently is)&lt;/TD&gt;
&lt;TD&gt;Address&lt;/TD&gt;
&lt;TD&gt;Referring Hx ID&lt;/TD&gt;
&lt;TD&gt;Ref Hx Address&lt;/TD&gt;
&lt;TD&gt;Receiving Hx ID&lt;/TD&gt;
&lt;TD&gt;Rec Hx Address&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;310 S X Ave&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;99&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;31 Y Ave&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;102&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;45 D Ave&lt;/TD&gt;
&lt;TD&gt;5&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;37&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;63 E Ave&lt;/TD&gt;
&lt;TD&gt;6&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Thu, 22 Feb 2024 23:21:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917487#M41052</guid>
      <dc:creator>Ihsan-Mahdi</dc:creator>
      <dc:date>2024-02-22T23:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning values based on another variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917488#M41053</link>
      <description>&lt;P&gt;In row 1, the receiving hospital ID is 3. How would we know what the address of hospital 3 is?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 23:23:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917488#M41053</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-02-22T23:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning values based on another variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917489#M41054</link>
      <description>&lt;P&gt;The Hospital ID is the same for each hospital regardless of it being admitting, referring, or receiving. So, a receiving hospital ID (3) in one record, and a referring hospital ID (3) in another record would be the same hospital but being a different place for a different patient. Each observation is a patient record.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 23:29:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917489#M41054</guid>
      <dc:creator>Ihsan-Mahdi</dc:creator>
      <dc:date>2024-02-22T23:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning values based on another variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917492#M41055</link>
      <description>&lt;P&gt;Below one way how to go about this that avoids creation of additional variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your sample data you don't provide an address for all hospital IDs and though you will only get formatted values for the IDs where there is somewhere in your data a matching address.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover dlm='|' dsd;
  input obs Hospital_ID Hospital_Name$ Address:$40. Referring_Hx_ID Receiving_Hx_ID;
  datalines;
1|8|A|310 S X Ave|.|3
2|99|B|31 Y Ave|.|102
3|102|C|45 D Ave|5|.
4|37|D|63 E Ave|6|.
;

proc sql;
  create view v_hospital_addresses as
  select distinct
    'hospital_name' as fmtname,
    'n' as type,
    Hospital_ID as start,
    address as label
  from have
  ;
quit;

proc format cntlin=v_hospital_addresses;
run;

proc print data=have;
  format hospital_id Referring_Hx_ID Receiving_Hx_ID hospital_name.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1708645298954.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94033i90745E00A33BB2E0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1708645298954.png" alt="Patrick_0-1708645298954.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 23:41:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917492#M41055</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-02-22T23:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning values based on another variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917493#M41056</link>
      <description>Thank you so much. I will try this and let you know. Really appreciate it!</description>
      <pubDate>Thu, 22 Feb 2024 23:47:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917493#M41056</guid>
      <dc:creator>Ihsan-Mahdi</dc:creator>
      <dc:date>2024-02-22T23:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning values based on another variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917494#M41057</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/333045"&gt;@Ihsan-Mahdi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you so much. I will try this and let you know. Really appreciate it!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Just as a feedback:&lt;/P&gt;
&lt;P&gt;I've spent more than half of my time for converting your table with sample data to a SAS data step have that creates the data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to help us help you then going forward please provide sample data via SAS code that creates the data same as I've done it in my data have step.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 23:54:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917494#M41057</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-02-22T23:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning values based on another variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917496#M41058</link>
      <description>&lt;P&gt;Just wondering, is there a way that involves creating new variables?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2024 00:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917496#M41058</guid>
      <dc:creator>Ihsan-Mahdi</dc:creator>
      <dc:date>2024-02-23T00:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning values based on another variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917497#M41059</link>
      <description>Will do. Sorry for the inconvenience and thanks again.</description>
      <pubDate>Fri, 23 Feb 2024 00:13:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917497#M41059</guid>
      <dc:creator>Ihsan-Mahdi</dc:creator>
      <dc:date>2024-02-23T00:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning values based on another variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917498#M41060</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/333045"&gt;@Ihsan-Mahdi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Just wondering, is there a way that involves creating new variables?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sure. Once you've got the format created you can use it to populate a new variable in a data step using code like:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Referring_Hx_addr=put(Referring_Hx_ID, hospital_name.);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2024 01:01:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917498#M41060</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-02-23T01:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning values based on another variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917501#M41061</link>
      <description>Excellent! Thank you!</description>
      <pubDate>Fri, 23 Feb 2024 01:11:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917501#M41061</guid>
      <dc:creator>Ihsan-Mahdi</dc:creator>
      <dc:date>2024-02-23T01:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning values based on another variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917546#M41069</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/333045"&gt;@Ihsan-Mahdi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The Hospital ID is the same for each hospital regardless of it being admitting, referring, or receiving. So, a receiving hospital ID (3) in one record, and a referring hospital ID (3) in another record would be the same hospital but being a different place for a different patient. Each observation is a patient record.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'm afraid this does not answer my question which was: How would we know what the address of hospital 3 is?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2024 10:25:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-values-based-on-another-variable/m-p/917546#M41069</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-02-23T10:25:58Z</dc:date>
    </item>
  </channel>
</rss>

