<?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: Same Variable Name - Different responses in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Same-Variable-Name-Different-responses/m-p/491749#M129042</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;It looks like you are on the right approach, although it's a little difficult&amp;nbsp;from your post, as your code &amp;amp; problem description don't appear to match (e.g. ED_LEVEL in the description vs HC_DEVLP in the code). &lt;BR /&gt;Also your code&amp;nbsp;appears to have several syntax&amp;nbsp;mistakes&lt;BR /&gt;Could you supply a small dummy sample of the input and the expected output (removing any personal&amp;nbsp;identifying information)&lt;BR /&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Fri, 31 Aug 2018 20:35:13 GMT</pubDate>
    <dc:creator>AMSAS</dc:creator>
    <dc:date>2018-08-31T20:35:13Z</dc:date>
    <item>
      <title>Same Variable Name - Different responses</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Same-Variable-Name-Different-responses/m-p/491738#M129036</link>
      <description>&lt;P&gt;I am working in a multi-year data set.&amp;nbsp; The problem I'm encountering is that I have the same variable name but they don't always have the same response category.&amp;nbsp; So in 2013,&lt;/P&gt;&lt;P&gt;ED_LEVEL= 1 = Less than 12th grade, no diploma&lt;/P&gt;&lt;P&gt;ED_LEVEL= 2 = High school graduate or GED completed&lt;/P&gt;&lt;P&gt;ED_LEVEL= 3 = Associate degree (AA, AS)&lt;/P&gt;&lt;P&gt;ED_LEVEL= 4 = Bachelor's degree(e.g., BA, BS)&lt;/P&gt;&lt;P&gt;ED_LEVEL= 5 = Master's degree (e.g., MA, MS)&lt;/P&gt;&lt;P&gt;ED_LEVEL= 6 = Doctorate (e.g., Phd, EdD)&amp;nbsp; or professional degree (e.g., MD, DDS)&lt;/P&gt;&lt;P&gt;ED_LEVEL= 9 = Don't Know&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But in 2015 the categories changed, now:&lt;/P&gt;&lt;P&gt;ED_LEVEL= 1 = Less than 12th grade, no diploma&lt;/P&gt;&lt;P&gt;ED_LEVEL= 2 = High school graduate or GED completed&lt;/P&gt;&lt;P&gt;ED_LEVEL= 3 = Technical/trade/vocational school completed&lt;/P&gt;&lt;P&gt;ED_LEVEL= 4 = Associate degree (AA, AS)&lt;/P&gt;&lt;P&gt;ED_LEVEL= 5 = Bachelor's degree(e.g., BA, BS)&lt;/P&gt;&lt;P&gt;ED_LEVEL= 6 = Master's degree (e.g., MA, MS)&lt;/P&gt;&lt;P&gt;ED_LEVEL= 7 = Professional degree (e.g., JD, MD, DDS)&lt;/P&gt;&lt;P&gt;ED_LEVEL= 8 = Doctorate (e.g., Phd, EdD)&amp;nbsp; or professional degree (e.g., MD, DDS)&lt;/P&gt;&lt;P&gt;ED_LEVEL= 9 = Don't Know&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;And just to spice things up a bit in 2012 the variable was:&lt;/P&gt;&lt;P&gt;EDU_M= 1 = 8th grade or less&lt;/P&gt;&lt;P&gt;EDU_M=&amp;nbsp;2 = 9th - 12th grade, no diploma&lt;/P&gt;&lt;P&gt;EDU_M=&amp;nbsp;3 = High school graduate or GED completed&lt;/P&gt;&lt;P&gt;EDU_M=&amp;nbsp;4 = Some college credit but no degree&lt;/P&gt;&lt;P&gt;EDU_M=&amp;nbsp;5 = Associate degree (AA, AS)&lt;/P&gt;&lt;P&gt;EDU_M=&amp;nbsp;6 = Bachelor's degree(e.g., BA, BS)&lt;/P&gt;&lt;P&gt;EDU_M=&amp;nbsp;7 = Master's degree (e.g., MA, MS)&lt;/P&gt;&lt;P&gt;EDU_M=&amp;nbsp;8 = Doctorate (e.g., Phd, EdD)&amp;nbsp; or professional degree (e.g., MD, DDS)&lt;/P&gt;&lt;P&gt;EDU_M=&amp;nbsp;9 = Don't Know&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am hoping to do is combine them all into a common variable: EDUCATION.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I have tried thus far is (on another variable):&lt;/P&gt;&lt;P&gt;do;&lt;/P&gt;&lt;P&gt;if year = '2008' or '2010' or '2011' or '2012' or '2013' then do;&lt;/P&gt;&lt;P&gt;if HC_DEVLP = 1 then DEV_DEL = 1;&lt;/P&gt;&lt;P&gt;else if HC_DEVLP = 2 then DEV_DEL = 2;&lt;/P&gt;&lt;P&gt;else if HC_DEVLP = 9 then DEV_DEL = 9;&lt;/P&gt;&lt;P&gt;else DEV_DEL='.';&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;if year = '2007' or '2014' or '2015' then do;&lt;/P&gt;&lt;P&gt;if HC_DEVLP = 1 then DEV_DEL2=1;&lt;/P&gt;&lt;P&gt;else if HC_DEVLP = 2 then DEV_DEL2=2;&lt;/P&gt;&lt;P&gt;else if HC_DEVLP = 9 then DEV_DEL2=9;&lt;/P&gt;&lt;P&gt;else if No5Developmentaldelay = 0 then DEV_DEL2 = 1;&lt;/P&gt;&lt;P&gt;else if No5Developmentaldelay = 1 then DEV_DEL2 = 2;&lt;/P&gt;&lt;P&gt;else DEV_DEL2='.';&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but that did not work so I am reaching out for some advice because I'm not having much luck figuring it out at this point.&lt;/P&gt;&lt;P&gt;Thanks Community.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 20:19:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Same-Variable-Name-Different-responses/m-p/491738#M129036</guid>
      <dc:creator>DanielQuay</dc:creator>
      <dc:date>2018-08-31T20:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: Same Variable Name - Different responses</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Same-Variable-Name-Different-responses/m-p/491743#M129039</link>
      <description>&lt;P&gt;This line is incorrect for starters:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if year = '2008' or '2010' or '2011' or '2012' or '2013' then do;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Should be:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;if year in (2008,  2010:2013) then do;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;You could also create 3 user define formats and apply them conditionally.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if year in (2013) then edu_format="ed1_fmt";
else if year in (2015) then edu_format= "ed2_fmt";
else if year in (2012) then edu_format= "ed3_fmt";

Education = putn(education_variable, edu_format);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/205036"&gt;@DanielQuay&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am working in a multi-year data set.&amp;nbsp; The problem I'm encountering is that I have the same variable name but they don't always have the same response category.&amp;nbsp; So in 2013,&lt;/P&gt;
&lt;P&gt;ED_LEVEL= 1 = Less than 12th grade, no diploma&lt;/P&gt;
&lt;P&gt;ED_LEVEL= 2 = High school graduate or GED completed&lt;/P&gt;
&lt;P&gt;ED_LEVEL= 3 = Associate degree (AA, AS)&lt;/P&gt;
&lt;P&gt;ED_LEVEL= 4 = Bachelor's degree(e.g., BA, BS)&lt;/P&gt;
&lt;P&gt;ED_LEVEL= 5 = Master's degree (e.g., MA, MS)&lt;/P&gt;
&lt;P&gt;ED_LEVEL= 6 = Doctorate (e.g., Phd, EdD)&amp;nbsp; or professional degree (e.g., MD, DDS)&lt;/P&gt;
&lt;P&gt;ED_LEVEL= 9 = Don't Know&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But in 2015 the categories changed, now:&lt;/P&gt;
&lt;P&gt;ED_LEVEL= 1 = Less than 12th grade, no diploma&lt;/P&gt;
&lt;P&gt;ED_LEVEL= 2 = High school graduate or GED completed&lt;/P&gt;
&lt;P&gt;ED_LEVEL= 3 = Technical/trade/vocational school completed&lt;/P&gt;
&lt;P&gt;ED_LEVEL= 4 = Associate degree (AA, AS)&lt;/P&gt;
&lt;P&gt;ED_LEVEL= 5 = Bachelor's degree(e.g., BA, BS)&lt;/P&gt;
&lt;P&gt;ED_LEVEL= 6 = Master's degree (e.g., MA, MS)&lt;/P&gt;
&lt;P&gt;ED_LEVEL= 7 = Professional degree (e.g., JD, MD, DDS)&lt;/P&gt;
&lt;P&gt;ED_LEVEL= 8 = Doctorate (e.g., Phd, EdD)&amp;nbsp; or professional degree (e.g., MD, DDS)&lt;/P&gt;
&lt;P&gt;ED_LEVEL= 9 = Don't Know&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;And just to spice things up a bit in 2012 the variable was:&lt;/P&gt;
&lt;P&gt;EDU_M= 1 = 8th grade or less&lt;/P&gt;
&lt;P&gt;EDU_M=&amp;nbsp;2 = 9th - 12th grade, no diploma&lt;/P&gt;
&lt;P&gt;EDU_M=&amp;nbsp;3 = High school graduate or GED completed&lt;/P&gt;
&lt;P&gt;EDU_M=&amp;nbsp;4 = Some college credit but no degree&lt;/P&gt;
&lt;P&gt;EDU_M=&amp;nbsp;5 = Associate degree (AA, AS)&lt;/P&gt;
&lt;P&gt;EDU_M=&amp;nbsp;6 = Bachelor's degree(e.g., BA, BS)&lt;/P&gt;
&lt;P&gt;EDU_M=&amp;nbsp;7 = Master's degree (e.g., MA, MS)&lt;/P&gt;
&lt;P&gt;EDU_M=&amp;nbsp;8 = Doctorate (e.g., Phd, EdD)&amp;nbsp; or professional degree (e.g., MD, DDS)&lt;/P&gt;
&lt;P&gt;EDU_M=&amp;nbsp;9 = Don't Know&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I am hoping to do is combine them all into a common variable: EDUCATION.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I have tried thus far is (on another variable):&lt;/P&gt;
&lt;P&gt;do;&lt;/P&gt;
&lt;P&gt;if year = '2008' or '2010' or '2011' or '2012' or '2013' then do;&lt;/P&gt;
&lt;P&gt;if HC_DEVLP = 1 then DEV_DEL = 1;&lt;/P&gt;
&lt;P&gt;else if HC_DEVLP = 2 then DEV_DEL = 2;&lt;/P&gt;
&lt;P&gt;else if HC_DEVLP = 9 then DEV_DEL = 9;&lt;/P&gt;
&lt;P&gt;else DEV_DEL='.';&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;if year = '2007' or '2014' or '2015' then do;&lt;/P&gt;
&lt;P&gt;if HC_DEVLP = 1 then DEV_DEL2=1;&lt;/P&gt;
&lt;P&gt;else if HC_DEVLP = 2 then DEV_DEL2=2;&lt;/P&gt;
&lt;P&gt;else if HC_DEVLP = 9 then DEV_DEL2=9;&lt;/P&gt;
&lt;P&gt;else if No5Developmentaldelay = 0 then DEV_DEL2 = 1;&lt;/P&gt;
&lt;P&gt;else if No5Developmentaldelay = 1 then DEV_DEL2 = 2;&lt;/P&gt;
&lt;P&gt;else DEV_DEL2='.';&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but that did not work so I am reaching out for some advice because I'm not having much luck figuring it out at this point.&lt;/P&gt;
&lt;P&gt;Thanks Community.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 20:25:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Same-Variable-Name-Different-responses/m-p/491743#M129039</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-31T20:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: Same Variable Name - Different responses</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Same-Variable-Name-Different-responses/m-p/491745#M129040</link>
      <description>&lt;P&gt;Thanks Reeza, I knew it was going to be something ridiculously simple but I was striking out.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 20:27:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Same-Variable-Name-Different-responses/m-p/491745#M129040</guid>
      <dc:creator>DanielQuay</dc:creator>
      <dc:date>2018-08-31T20:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: Same Variable Name - Different responses</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Same-Variable-Name-Different-responses/m-p/491749#M129042</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;It looks like you are on the right approach, although it's a little difficult&amp;nbsp;from your post, as your code &amp;amp; problem description don't appear to match (e.g. ED_LEVEL in the description vs HC_DEVLP in the code). &lt;BR /&gt;Also your code&amp;nbsp;appears to have several syntax&amp;nbsp;mistakes&lt;BR /&gt;Could you supply a small dummy sample of the input and the expected output (removing any personal&amp;nbsp;identifying information)&lt;BR /&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 20:35:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Same-Variable-Name-Different-responses/m-p/491749#M129042</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2018-08-31T20:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: Same Variable Name - Different responses</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Same-Variable-Name-Different-responses/m-p/491766#M129052</link>
      <description>&lt;P&gt;An alternate approach is to create a custom informat that takes any of the text values and will create a "standard" coding level (create with more levels than you think you may need at first sometimes helps), use that informat to create a standardized variable and have a custom format for the levels to display meaningful standard text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a project that has increased the number of "values" from&amp;nbsp; 20 the first year to over 40 after 5 years. But they need to get mapped to 5 report categories. This way I only have to add one or two lines to the Informat part for the "new values". By having the informat definition with an other=_error_ option then I get the invalid data diagnostic in the log and need not spend a lot of time pre-validating any "new" codes.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 21:57:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Same-Variable-Name-Different-responses/m-p/491766#M129052</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-31T21:57:43Z</dc:date>
    </item>
  </channel>
</rss>

