<?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: Question with ordering variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Question-with-ordering-variables/m-p/151937#M262553</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you not put the order of variables into a macro variable as you go along, then datastep retain &amp;amp;m_variable. after the proc freq?&amp;nbsp; E.g. (not tested)&lt;/P&gt;&lt;P&gt;... &lt;/P&gt;&lt;P&gt;retain col_ord;&lt;/P&gt;&lt;P&gt;if q101r1 then do;&lt;/P&gt;&lt;P&gt;healthhad='Private insurance that is provided by your current or former employer or union' ;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;col_ord =strip(col_ord)||" "||"q101r1";&lt;/P&gt;&lt;P&gt;if q101r2 then do;&lt;/P&gt;&lt;P&gt;healthhad=' Insurance that is provided through a family members employer or union' ;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;col_ord =strip(col_ord)||" "||"q101r1"; &lt;/P&gt;&lt;P&gt;if last record then call symput('COL_ORD',strip(col_ord);&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set freq;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; retain &amp;amp;col_ord;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Mar 2014 14:59:47 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2014-03-21T14:59:47Z</dc:date>
    <item>
      <title>Question with ordering variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-with-ordering-variables/m-p/151934#M262550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have created a variable 'healthhad'.&amp;nbsp; When running the proc freq procedure, I would like the response options to appear in the order as the code is written. &lt;/P&gt;&lt;P&gt;I have tried numerous order=formatted/data/freq/internal statements, however these do not work. Any suggestions? Thanks! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new/view=new;&lt;/P&gt;&lt;P&gt;set work.PWL_SPSS ;/*CREATING "TYPE OF HEALTH INSURANCE DID YOU HAVE"*/&lt;/P&gt;&lt;P&gt;length healthhad $44;&lt;/P&gt;&lt;P&gt;keep healthhad;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if q101r1 then do;&lt;/P&gt;&lt;P&gt;healthhad='Private insurance that is provided by your current or former employer or union' ;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if q101r2 then do;&lt;/P&gt;&lt;P&gt;healthhad=' Insurance that is provided through a family members employer or union' ;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if q101r3 then do;&lt;/P&gt;&lt;P&gt;healthhad='Private insurance that was purchased directly from an insurance company' ;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if q101r4 then do;&lt;/P&gt;&lt;P&gt;healthhad='Medicare, for people 65 and older' ;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if q101r5 then do;&lt;/P&gt;&lt;P&gt;healthhad=' Medicare, for people with certain disabilities' ;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if q101r6 then do;&lt;/P&gt;&lt;P&gt;healthhad='Medicare supplemental insurance ';&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if q101r7 then do;&lt;/P&gt;&lt;P&gt;healthhad='Medicaid' ;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if q101r8 then do;&lt;/P&gt;&lt;P&gt;healthhad='TRICARE' ;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if q101r9 then do;&lt;/P&gt;&lt;P&gt;healthhad='Veterans Affairs' ;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if q101r10 then do;&lt;/P&gt;&lt;P&gt;healthhad=' Indian Health Service' ;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if q101r11 then do;&lt;/P&gt;&lt;P&gt;healthhad='I did not have health insurance' ;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if q101r12 then do;&lt;/P&gt;&lt;P&gt;healthhad='Do not know/Not sure' ;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=new order=data;&lt;/P&gt;&lt;P&gt;tables healthhad /nocum nocol;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=new order=data;&lt;/P&gt;&lt;P&gt;tables healthhad /nocum nocol;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 13:45:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-with-ordering-variables/m-p/151934#M262550</guid>
      <dc:creator>GregBond</dc:creator>
      <dc:date>2014-03-21T13:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: Question with ordering variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-with-ordering-variables/m-p/151935#M262551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Proc Freq does not appear to have the flexibility you require to preserve a particular order in summary reporting.&amp;nbsp; Tabulate, Means and Report all allow ordering by a prearranged format.&amp;nbsp; To implement tis you need to create the format using the NOTSORTED option , and then report specifying both ORDER=DATA and PRELOADFMT options.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See&amp;nbsp; &lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473473.htm#a003281517" title="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473473.htm#a003281517"&gt;Base SAS(R) 9.2 Procedures Guide&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would suggest creating the healthhad format as&lt;/P&gt;&lt;P&gt;Proc Format ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Value $healthhad NOTSORTED&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'q101r1' &lt;SPAN style="line-height: 1.5em;"&gt;= 'Private insurance that is provided by your current or former employer or union'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'q101r2' &lt;/SPAN&gt;&lt;SPAN style="line-height: 1.5em;"&gt;= ' Insurance that is provided through a family members employer or union' &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [etc]&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="line-height: 1.5em;"&gt;Then code your data using coded values for the column helathhad&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="line-height: 1.5em;"&gt;Data want ; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set have ;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format healthhad $healthhad. ;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Select ;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; When &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;q101r1&lt;/SPAN&gt; then &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;healthhad&lt;/SPAN&gt; = &lt;SPAN style="line-height: 1.5em;"&gt; '&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;q101r1' ;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; When &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;q101r2&lt;/SPAN&gt; then &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;healthhad&lt;/SPAN&gt; =&amp;nbsp; '&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;q101r2' ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [etc]&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Otherwise ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;Run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;Then use Proc Tabulate or Report to count and report the values.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;Richard&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.800000190734863px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="line-height: 1.5em;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 14:17:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-with-ordering-variables/m-p/151935#M262551</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2014-03-21T14:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: Question with ordering variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-with-ordering-variables/m-p/151936#M262552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An alternate approach would be to code the variable healthhad as numeric in the order you wish them to appear and use the Order=Internal option on proc freq statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Array processing would simplify the coding as well&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Array Q101 Q101r: ; /* assumes all of the Q101rx variables are to be recoded*/&lt;/P&gt;&lt;P&gt;Do _i_ = 1 to dim (Q101);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if q101[_i_] then healthhad = _i_;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since questionaires often have a response section like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.&amp;nbsp;&amp;nbsp;&amp;nbsp; Private insurance that was purchased directly from an insurance company&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Insurance that is provided through a family members employer or union&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;etc&lt;/P&gt;&lt;P&gt;it is easy to do a copy and paste to make a custom format&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;value HealthHad&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1=&amp;nbsp;&amp;nbsp; 'Private insurance that was purchased directly from an insurance company'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2=&amp;nbsp;&amp;nbsp; 'Insurance that is provided through a family members employer or union'&lt;/P&gt;&lt;P&gt;&amp;lt;more lines here&amp;gt;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Done this say more times than I want to think about.&lt;/P&gt;&lt;P&gt;By the way, the Format approach has an added bonus. You don't have to add variables if you later need to group your responses such as&lt;/P&gt;&lt;P&gt;1,2 and 3 to indicate private insurance, or 4,5,6 as medicare:&lt;/P&gt;&lt;P&gt;Proc format;&lt;/P&gt;&lt;P&gt;value HeathInsGroup&lt;/P&gt;&lt;P&gt;1,2,3 = 'Private insurance'&lt;/P&gt;&lt;P&gt;4,5,6 = 'Medicare'&lt;/P&gt;&lt;P&gt;&amp;lt;other group or single values&amp;gt;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;Then you only have to change the format for analysis. The formatted group values will also work when used as categorical variables in most analysis procedures.&lt;/P&gt;&lt;P&gt;I strongly recommend at least trying this a few times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And a later thought, some survey software I have used has options for exporting variables and single choice multiple response questions like this could be exported in a number of manners. One defaulted to multiple dichotomous variables such as you show but there was an option to export a single variable with the choice value. It may be too late for this project but something to bring up with your data collection side. There really shouldn't be a need to do as much work like this if the software will do it automatically. Your data set name makes me believe it went through SPSS at some point. If the data were exported as I suggest it could be possible for SPSS to export the data AND generate a SAS program file for formats of the value labels. Can't hurt to explore this&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 14:51:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-with-ordering-variables/m-p/151936#M262552</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-03-21T14:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: Question with ordering variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-with-ordering-variables/m-p/151937#M262553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you not put the order of variables into a macro variable as you go along, then datastep retain &amp;amp;m_variable. after the proc freq?&amp;nbsp; E.g. (not tested)&lt;/P&gt;&lt;P&gt;... &lt;/P&gt;&lt;P&gt;retain col_ord;&lt;/P&gt;&lt;P&gt;if q101r1 then do;&lt;/P&gt;&lt;P&gt;healthhad='Private insurance that is provided by your current or former employer or union' ;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;col_ord =strip(col_ord)||" "||"q101r1";&lt;/P&gt;&lt;P&gt;if q101r2 then do;&lt;/P&gt;&lt;P&gt;healthhad=' Insurance that is provided through a family members employer or union' ;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;col_ord =strip(col_ord)||" "||"q101r1"; &lt;/P&gt;&lt;P&gt;if last record then call symput('COL_ORD',strip(col_ord);&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set freq;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; retain &amp;amp;col_ord;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 14:59:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-with-ordering-variables/m-p/151937#M262553</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-03-21T14:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: Question with ordering variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-with-ordering-variables/m-p/151938#M262554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Richard, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your insightful responses. I will look over each and get back to as to which works the best.&amp;nbsp; Thanks again, as you have been a huge help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 15:05:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-with-ordering-variables/m-p/151938#M262554</guid>
      <dc:creator>GregBond</dc:creator>
      <dc:date>2014-03-21T15:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: Question with ordering variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-with-ordering-variables/m-p/151939#M262555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are a number of good ideas already posted here.&amp;nbsp; One simple possibility would be to change the value of healthhad, such as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;length healthhad $ 49;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if q101r1 then do;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;healthhad='r01: Private insurance that is provided by your current or former employer or union' ;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;output;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;end;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;If that's an acceptable approach, it should be easy to implement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 16:54:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-with-ordering-variables/m-p/151939#M262555</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-03-21T16:54:51Z</dc:date>
    </item>
  </channel>
</rss>

