<?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: Error 22-322 when set reference levels for CLASS predictor variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-22-322-when-set-reference-levels-for-CLASS-predictor/m-p/608044#M176898</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/301563"&gt;@yilijiaer&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a post that could answer your questions:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/Changing-reference-level-for-categorical-variable-in-PROC/td-p/56740" target="_self"&gt;https://communities.sas.com/t5/SAS-Procedures/Changing-reference-level-for-categorical-variable-in-PROC/td-p/56740&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
    <pubDate>Thu, 28 Nov 2019 12:41:34 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2019-11-28T12:41:34Z</dc:date>
    <item>
      <title>Error 22-322 when set reference levels for CLASS predictor variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-22-322-when-set-reference-levels-for-CLASS-predictor/m-p/608032#M176894</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I want to use bcd4=1 as the reference level, but&amp;nbsp;there is Error 22-322 and I would like someone to help with it, thank you!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data workdata;set workdata;
if LBDBCDSI&amp;lt;=1.78 then bcd4=1;
if 1.78&amp;lt;LBDBCDSI&amp;lt;=3.56 then bcd4=2;
if 3.56&amp;lt;LBDBCDSI&amp;lt;=6.23 then bcd4=3;
if 6.23&amp;lt;LBDBCDSI then bcd4=4;
run; 

proc univariate data=workdata2; var urine_cd; weight WTSHM6YR;run; /* take down the min, 25%, 50%, 75%, and the max value. */
data workdata2;set workdata2;
if urine_cd&amp;lt;=1.38 then ucd4=1;
if 1.38&amp;lt;urine_cd&amp;lt;=2.69 then ucd4=2;
if 2.69&amp;lt;urine_cd&amp;lt;=5.09 then ucd4=3;
if 5.09&amp;lt;urine_cd then ucd4=4;
run; 

/* fit data by using restricted cubic splines */
ods select ANOVA ParameterEstimates SplineKnots;
proc glmselect data=workdata;
  effect spl = spline(RIDAGEYR / details naturalcubic basis=tpf(noint)                 
                               knotmethod=percentiles(5) );
   model LBDBCDSI = spl / selection=none;         /* fit model by using spline effects */
   output out=SplineOut predicted=Fit;            /* output predicted values for graphing */
quit;
 
title "Restricted Cubic Spline Regression";
proc sgplot data=SplineOut noautolegend;
   scatter x=RIDAGEYR y=LBDBCDSI;
   series x=RIDAGEYR y=Fit / lineattrs=(thickness=3 color=red);
run;

/*model_1*/
data workdata;set workdata;/*years modeled as restricted cubic spline with 5 knots*/
if RIDAGEYR&amp;lt;=30 then age=1;
if 30&amp;lt;RIDAGEYR&amp;lt;=40 then age=2;
if 40&amp;lt;RIDAGEYR&amp;lt;=49 then age=3;
if 49&amp;lt;RIDAGEYR&amp;lt;=61 then age=4;
if 61&amp;lt;RIDAGEYR&amp;lt;=71 then age=5;
if 71&amp;lt;RIDAGEYR then age=6;
run;

data workdata;set workdata;/*education*/
if DMDEDUC=1 then edu=1;
if DMDEDUC=2 then edu=2;
if DMDEDUC=3 then edu=3;
run;

data workdata;set workdata;/*race*/
if RIDRETH1=3 then race=0;
else if RIDRETH1=4 then race=1;
else if RIDRETH1=1 then race=2;
else race=3;
run;

/*linear regression-model1-blood cd*/
proc surveyreg data=workdata;
class bcd4 (ref='1') age RIAGENDR race edu;
model BPXSAR=bcd4 age RIAGENDR race edu/ vadjust=none;
stratum sdmvstra;
cluster sdmvpsu;
weight wtmec6yr;
run;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Nov 2019 13:29:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-22-322-when-set-reference-levels-for-CLASS-predictor/m-p/608032#M176894</guid>
      <dc:creator>yilijiaer</dc:creator>
      <dc:date>2019-11-28T13:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: Error 22-322 when set reference levels for CLASS predictor variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-22-322-when-set-reference-levels-for-CLASS-predictor/m-p/608044#M176898</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/301563"&gt;@yilijiaer&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a post that could answer your questions:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/Changing-reference-level-for-categorical-variable-in-PROC/td-p/56740" target="_self"&gt;https://communities.sas.com/t5/SAS-Procedures/Changing-reference-level-for-categorical-variable-in-PROC/td-p/56740&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Thu, 28 Nov 2019 12:41:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-22-322-when-set-reference-levels-for-CLASS-predictor/m-p/608044#M176898</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-11-28T12:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: Error 22-322 when set reference levels for CLASS predictor variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-22-322-when-set-reference-levels-for-CLASS-predictor/m-p/608045#M176899</link>
      <description>&lt;P&gt;Please do not mix code and log text. Either show the log from the beginning, or the code. It could well be that your problem is caused by something from line 674 up.&lt;/P&gt;
&lt;P&gt;And supply some example data in usable form (data step with datalines) so we have something to play around with.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Nov 2019 12:53:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-22-322-when-set-reference-levels-for-CLASS-predictor/m-p/608045#M176899</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-28T12:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: Error 22-322 when set reference levels for CLASS predictor variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-22-322-when-set-reference-levels-for-CLASS-predictor/m-p/608048#M176902</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data workdata;set workdata;
if LBDBCDSI&amp;lt;=1.78 then bcd=1;
if 1.78&amp;lt;LBDBCDSI&amp;lt;=3.56 then bcd=2;
if 3.56&amp;lt;LBDBCDSI&amp;lt;=6.23 then bcd=3;
if 6.23&amp;lt;LBDBCDSI then bcd=4;
run; 

proc format;
     value $bcd
          '1' = 'D Q1'
          '2' = 'A Q2'
          '3' = 'B Q3'
          '4' = 'C Q4';
run;
proc surveyreg order=formatted data=workdata;
     class bcd;     format bcd $bcd.;

proc surveyreg data=workdata; 
class bcd(ref='1') age RIAGENDR race edu;
model BPXSAR=bcd4 age RIAGENDR race edu/ vadjust=none; 
stratum sdmvstra;  
cluster sdmvpsu;  
weight wtmec6yr; 
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you! I tried this one, but it still does not work.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Nov 2019 13:25:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-22-322-when-set-reference-levels-for-CLASS-predictor/m-p/608048#M176902</guid>
      <dc:creator>yilijiaer</dc:creator>
      <dc:date>2019-11-28T13:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: Error 22-322 when set reference levels for CLASS predictor variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-22-322-when-set-reference-levels-for-CLASS-predictor/m-p/608055#M176907</link>
      <description>&lt;P&gt;If you aren’t running your code start to finish each time, you’re likely overwriting for data set workdata multiple times. I suggest changing the output name for each step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you need bcd to be character eventually why not define it that way to begin with?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data workdata2;set workdata;
if LBDBCDSI&amp;lt;=1.78 then bcd='1';
if 1.78&amp;lt;LBDBCDSI&amp;lt;=3.56 then bcd='2';
if 3.56&amp;lt;LBDBCDSI&amp;lt;=6.23 then bcd='3';
if 6.23&amp;lt;LBDBCDSI then bcd='4';
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;-unison&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Nov 2019 13:54:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-22-322-when-set-reference-levels-for-CLASS-predictor/m-p/608055#M176907</guid>
      <dc:creator>unison</dc:creator>
      <dc:date>2019-11-28T13:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: Error 22-322 when set reference levels for CLASS predictor variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-22-322-when-set-reference-levels-for-CLASS-predictor/m-p/608057#M176908</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/301563"&gt;@yilijiaer&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reason for the error &lt;SPAN&gt;22-322&amp;nbsp;&lt;/SPAN&gt;is that you're using a relatively old release of SAS/STAT, probably SAS/STAT &lt;STRONG&gt;13.2&lt;/STRONG&gt; or earlier. You can verify this by submitting this step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc product_status;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The REF= option after a CLASS variable is mentioned in the &lt;A href="http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_surveyreg_syntax03.htm" target="_blank" rel="noopener"&gt;PROC SURVEYREG documentation of SAS/STAT 14.1&lt;/A&gt; and later releases. So, you should use the ORDER= technique that has been suggested &lt;EM&gt;and&lt;/EM&gt; omit the "&lt;FONT face="courier new,courier"&gt;(ref='1')&lt;/FONT&gt;" option in the CLASS statement. It doesn't matter if variable &lt;FONT face="courier new,courier"&gt;bcd&lt;/FONT&gt; is numeric or character, but the type of the format must match the type of the variable (i.e., either make &lt;FONT face="courier new,courier"&gt;bcd&lt;/FONT&gt; a character variable as unison has suggested or create a &lt;EM&gt;numeric&lt;/EM&gt; format without a $ sign before its name and without single quotes on the left of the equals signs).&lt;/P&gt;</description>
      <pubDate>Thu, 28 Nov 2019 14:34:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-22-322-when-set-reference-levels-for-CLASS-predictor/m-p/608057#M176908</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-11-28T14:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: Error 22-322 when set reference levels for CLASS predictor variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-22-322-when-set-reference-levels-for-CLASS-predictor/m-p/608227#M176987</link>
      <description>&lt;P&gt;Yes, you are right, I am using&amp;nbsp;&lt;SPAN&gt;SAS/STAT&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;13.2.&amp;nbsp;&lt;/STRONG&gt;I think it is the reason. Could you give me an example of using "order=" in CLASS statement to set&amp;nbsp;reference levels? Thank you so much!&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 11:28:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-22-322-when-set-reference-levels-for-CLASS-predictor/m-p/608227#M176987</guid>
      <dc:creator>yilijiaer</dc:creator>
      <dc:date>2019-11-29T11:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: Error 22-322 when set reference levels for CLASS predictor variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-22-322-when-set-reference-levels-for-CLASS-predictor/m-p/608230#M176989</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/301563"&gt;@yilijiaer&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;Could you give me an example of using "order=" in CLASS statement to set&amp;nbsp;reference levels?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Just correct the example in your own post:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create a &lt;EM&gt;numeric&lt;/EM&gt; format for the numeric variable &lt;FONT face="courier new,courier"&gt;bcd&lt;/FONT&gt;:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value bcd
1 = 'D Q1'
...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;Modify the PROC SURVEYREG step similarly to what you did already below your PROC FORMAT step:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc surveyreg data=workdata order=formatted;
class bcd age ...;
format bcd bcd.;
model ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Fri, 29 Nov 2019 11:55:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-22-322-when-set-reference-levels-for-CLASS-predictor/m-p/608230#M176989</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-11-29T11:55:41Z</dc:date>
    </item>
  </channel>
</rss>

