<?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: Do loop creating extra observations and variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-creating-extra-observations-and-variables/m-p/776978#M247126</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;&lt;FONT color="#0000FF"&gt;data&lt;/FONT&gt; perm.temp; 
 &lt;FONT color="#0000FF"&gt;set&lt;/FONT&gt; perm.mentalhealth; 
&lt;FONT color="#0000FF"&gt; array&lt;/FONT&gt; var_list[9] trouble_sleeping hurting_yourself interest depressed little_energy appetite feeling_bad &lt;BR /&gt; concentrating moving_slowly;
 &lt;FONT color="#0000FF"&gt;do&lt;/FONT&gt; i=&lt;FONT color="#339966"&gt;1&lt;/FONT&gt; to dim(var_list);
  VarName=vname(var_list(i));
  Outcome=var_list[i];
 &lt;FONT color="#0000FF"&gt; output&lt;/FONT&gt;;
&lt;FONT color="#0000FF"&gt;end&lt;/FONT&gt;;
 &lt;FONT color="#0000FF"&gt;array&lt;/FONT&gt; categorical[22]  gender age scalp_lesions postauricular erythema eyelid_involvement cheilitis flexural_erythema&lt;BR /&gt; xerosis neck_folds nipple_eczema keratosis palmar hand_eczema ichthyosis foot_eczema race education_final insurance &lt;BR /&gt; alopecia pityriasis pain_severeB;
 &lt;FONT color="#0000FF"&gt;do&lt;/FONT&gt; j=&lt;FONT color="#339966"&gt;1&lt;/FONT&gt; to dim(categorical);
  categorical_=vvalue(categorical(j));
 &lt;FONT color="#0000FF"&gt; output&lt;/FONT&gt;;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;end&lt;/FONT&gt;;
&lt;FONT color="#0000FF"&gt;array&lt;/FONT&gt; npredictors[9] SCORAD EASI BSA ADSI POEM_SCORE dlqi_score FIVED_SCORE RL_SCORE flare;
&lt;FONT color="#0000FF"&gt;do&lt;/FONT&gt; k=&lt;FONT color="#339966"&gt;1&lt;/FONT&gt; to dim(npredictors);
  npredictors_=vname(npredictors(k));
  &lt;FONT color="#0000FF"&gt;output&lt;/FONT&gt;;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;end&lt;/FONT&gt;;
&lt;FONT color="#0000FF"&gt;format&lt;/FONT&gt; Depression &lt;FONT color="#008000"&gt;Depressionn.&lt;/FONT&gt; Anxiety &lt;FONT color="#008000"&gt;Anxietyy.&lt;/FONT&gt; interest &lt;FONT color="#008000"&gt;interestt.&lt;/FONT&gt; depressed &lt;FONT color="#008000"&gt;_depressedd&lt;/FONT&gt;. trouble_sleeping &lt;FONT color="#008000"&gt;trouble_sleepingg&lt;/FONT&gt;. &lt;BR /&gt;little_energy &lt;FONT color="#008000"&gt;little_energyy.&lt;/FONT&gt; appetite&lt;FONT color="#008000"&gt; appetitee.&lt;/FONT&gt; feeling_bad &lt;FONT color="#008000"&gt;feeling_badd.&lt;/FONT&gt; concentrating &lt;FONT color="#008000"&gt;concentratingg.&lt;/FONT&gt; &lt;BR /&gt;moving_slowly &lt;FONT color="#008000"&gt;moving_slowlyy.&lt;/FONT&gt; hurting_yourself &lt;FONT color="#008000"&gt;hurting_yourselff.&lt;/FONT&gt; PHQ9_SCORE &lt;FONT color="#008000"&gt;PHQ9_SCORE_.&lt;/FONT&gt; PHQ2_SCORE&lt;FONT color="#008000"&gt; PHQ2_SCORE&lt;/FONT&gt;. &lt;BR /&gt;gender &lt;FONT color="#008000"&gt;gender&lt;/FONT&gt;. race &lt;FONT color="#008000"&gt;race.&lt;/FONT&gt; education_final &lt;FONT color="#008000"&gt;education.&lt;/FONT&gt; insurance &lt;FONT color="#008000"&gt;insurance&lt;/FONT&gt;. scalp_lesions &lt;FONT color="#008000"&gt;scalp_lesionss.&lt;/FONT&gt; postauricular&lt;FONT color="#008000"&gt; postauricularr&lt;/FONT&gt;. &lt;BR /&gt;erythema &lt;FONT color="#008000"&gt;erythemaa.&lt;/FONT&gt; eyelid_involvement&lt;FONT color="#008000"&gt; eyelid_involvementt. &lt;/FONT&gt;cheilitis &lt;FONT color="#008000"&gt;cheilitiss.&lt;/FONT&gt; flexural_erythema &lt;FONT color="#008000"&gt;flexural_erythemaa.&lt;/FONT&gt; &lt;BR /&gt;xerosis &lt;FONT color="#008000"&gt;xerosiss.&lt;/FONT&gt; neck_folds &lt;FONT color="#008000"&gt;neck_foldss.&lt;/FONT&gt; nipple_eczema &lt;FONT color="#008000"&gt;nipple_eczemaa.&lt;/FONT&gt; keratosis &lt;FONT color="#008000"&gt;keratosiss.&lt;/FONT&gt; palmar&lt;FONT color="#008000"&gt; palmarr.&lt;/FONT&gt; &lt;BR /&gt;hand_eczema &lt;FONT color="#008000"&gt;hand_eczemaa.&lt;/FONT&gt; ichthyosis &lt;FONT color="#008000"&gt;ichthyosiss.&lt;/FONT&gt; foot_eczema &lt;FONT color="#008000"&gt;foot_eczemaa.&lt;/FONT&gt; age &lt;FONT color="#008000"&gt;age_bin_.&lt;/FONT&gt; alopecia &lt;FONT color="#008000"&gt;alopeciaa.&lt;/FONT&gt; &lt;BR /&gt;pityriasis&lt;FONT color="#008000"&gt; pityriasiss.&lt;/FONT&gt; pain_severeB&lt;FONT color="#008000"&gt; painn.&lt;/FONT&gt; ;
&lt;FONT color="#0000FF"&gt;run&lt;/FONT&gt;; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Sorry about that. Does this help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Oct 2021 14:16:30 GMT</pubDate>
    <dc:creator>393310</dc:creator>
    <dc:date>2021-10-28T14:16:30Z</dc:date>
    <item>
      <title>Do loop creating extra observations and variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-creating-extra-observations-and-variables/m-p/776972#M247121</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created 3 do loops for the purpose of being able to cycle through 3 different types of variables (dependent, categorical, and continuous). When I run the loop it works, but I noticed that the number of observations went from 950 to 38,000 and 94 to 101 variables. I believe I should have only created 3 new variables. Any ideas why this is happening? I believe the extra observations are throwing off the results for my subsequent functions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;&lt;FONT color="#0000FF"&gt;data&lt;/FONT&gt; perm.temp; 
 &lt;FONT color="#0000FF"&gt;set&lt;/FONT&gt; perm.mentalhealth; 
&lt;FONT color="#0000FF"&gt; array&lt;/FONT&gt; var_list[9] trouble_sleeping hurting_yourself interest depressed little_energy appetite feeling_bad &lt;BR /&gt; concentrating moving_slowly;
 &lt;FONT color="#0000FF"&gt;do&lt;/FONT&gt; i=&lt;FONT color="#339966"&gt;1&lt;/FONT&gt; to dim(var_list);
  VarName=vname(var_list(i));
  Outcome=var_list[i];
 &lt;FONT color="#0000FF"&gt; output&lt;/FONT&gt;;
&lt;FONT color="#0000FF"&gt;end&lt;/FONT&gt;;
 &lt;FONT color="#0000FF"&gt;array&lt;/FONT&gt; categorical[22]  gender age scalp_lesions postauricular erythema eyelid_involvement cheilitis flexural_erythema&lt;BR /&gt; xerosis neck_folds nipple_eczema keratosis palmar hand_eczema ichthyosis foot_eczema race education_final insurance &lt;BR /&gt; alopecia pityriasis pain_severeB;
 &lt;FONT color="#0000FF"&gt;do&lt;/FONT&gt; j=&lt;FONT color="#339966"&gt;1&lt;/FONT&gt; to dim(categorical);
  categorical_=vvalue(categorical(j));
 &lt;FONT color="#0000FF"&gt; output&lt;/FONT&gt;;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;end&lt;/FONT&gt;;
&lt;FONT color="#0000FF"&gt;array&lt;/FONT&gt; npredictors[9] SCORAD EASI BSA ADSI POEM_SCORE dlqi_score FIVED_SCORE RL_SCORE flare;
&lt;FONT color="#0000FF"&gt;do&lt;/FONT&gt; k=&lt;FONT color="#339966"&gt;1&lt;/FONT&gt; to dim(npredictors);
  npredictors_=vname(npredictors(k));
  &lt;FONT color="#0000FF"&gt;output&lt;/FONT&gt;;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;end&lt;/FONT&gt;;
&lt;FONT color="#0000FF"&gt;format&lt;/FONT&gt; Depression &lt;FONT color="#008000"&gt;Depressionn.&lt;/FONT&gt; Anxiety &lt;FONT color="#008000"&gt;Anxietyy.&lt;/FONT&gt; interest &lt;FONT color="#008000"&gt;interestt.&lt;/FONT&gt; depressed &lt;FONT color="#008000"&gt;_depressedd&lt;/FONT&gt;. trouble_sleeping &lt;FONT color="#008000"&gt;trouble_sleepingg&lt;/FONT&gt;. &lt;BR /&gt;little_energy &lt;FONT color="#008000"&gt;little_energyy.&lt;/FONT&gt; appetite&lt;FONT color="#008000"&gt; appetitee.&lt;/FONT&gt; feeling_bad &lt;FONT color="#008000"&gt;feeling_badd.&lt;/FONT&gt; concentrating &lt;FONT color="#008000"&gt;concentratingg.&lt;/FONT&gt; &lt;BR /&gt;moving_slowly &lt;FONT color="#008000"&gt;moving_slowlyy.&lt;/FONT&gt; hurting_yourself &lt;FONT color="#008000"&gt;hurting_yourselff.&lt;/FONT&gt; PHQ9_SCORE &lt;FONT color="#008000"&gt;PHQ9_SCORE_.&lt;/FONT&gt; PHQ2_SCORE&lt;FONT color="#008000"&gt; PHQ2_SCORE&lt;/FONT&gt;. &lt;BR /&gt;gender &lt;FONT color="#008000"&gt;gender&lt;/FONT&gt;. race &lt;FONT color="#008000"&gt;race.&lt;/FONT&gt; education_final &lt;FONT color="#008000"&gt;education.&lt;/FONT&gt; insurance &lt;FONT color="#008000"&gt;insurance&lt;/FONT&gt;. scalp_lesions &lt;FONT color="#008000"&gt;scalp_lesionss.&lt;/FONT&gt; postauricular&lt;FONT color="#008000"&gt; postauricularr&lt;/FONT&gt;. &lt;BR /&gt;erythema &lt;FONT color="#008000"&gt;erythemaa.&lt;/FONT&gt; eyelid_involvement&lt;FONT color="#008000"&gt; eyelid_involvementt. &lt;/FONT&gt;cheilitis &lt;FONT color="#008000"&gt;cheilitiss.&lt;/FONT&gt; flexural_erythema &lt;FONT color="#008000"&gt;flexural_erythemaa.&lt;/FONT&gt; &lt;BR /&gt;xerosis &lt;FONT color="#008000"&gt;xerosiss.&lt;/FONT&gt; neck_folds &lt;FONT color="#008000"&gt;neck_foldss.&lt;/FONT&gt; nipple_eczema &lt;FONT color="#008000"&gt;nipple_eczemaa.&lt;/FONT&gt; keratosis &lt;FONT color="#008000"&gt;keratosiss.&lt;/FONT&gt; palmar&lt;FONT color="#008000"&gt; palmarr.&lt;/FONT&gt; &lt;BR /&gt;hand_eczema &lt;FONT color="#008000"&gt;hand_eczemaa.&lt;/FONT&gt; ichthyosis &lt;FONT color="#008000"&gt;ichthyosiss.&lt;/FONT&gt; foot_eczema &lt;FONT color="#008000"&gt;foot_eczemaa.&lt;/FONT&gt; age &lt;FONT color="#008000"&gt;age_bin_.&lt;/FONT&gt; alopecia &lt;FONT color="#008000"&gt;alopeciaa.&lt;/FONT&gt; &lt;BR /&gt;pityriasis&lt;FONT color="#008000"&gt; pityriasiss.&lt;/FONT&gt; pain_severeB&lt;FONT color="#008000"&gt; painn.&lt;/FONT&gt; ;
&lt;FONT color="#0000FF"&gt;run&lt;/FONT&gt;; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="schatr2_0-1635429292525.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65129i4BB40B036B654F16/image-size/medium?v=v2&amp;amp;px=400" role="button" title="schatr2_0-1635429292525.png" alt="schatr2_0-1635429292525.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 14:17:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-creating-extra-observations-and-variables/m-p/776972#M247121</guid>
      <dc:creator>393310</dc:creator>
      <dc:date>2021-10-28T14:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop creating extra observations and variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-creating-extra-observations-and-variables/m-p/776974#M247123</link>
      <description>&lt;P&gt;So first, I don't know the answer to your question, because I find your code difficult to read and it would help us all if your code was properly indented and formatted, and lines didn't extend beyond the right edge of the text box. Example of proper indentation and formatting:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data perm.temp; 
    set perm.mentalhealth; 
    array var_list[9] trouble_sleeping hurting_yourself interest depressed little_energy appetite feeling_bad
         concentrating moving_slowly;
    do i=1 to dim(var_list);
        VarName=vname(var_list(i));
        Outcome=var_list[i];
        output;
    end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So, I am asking you to take the time and re-format your code such that it is more readable, and then I would be happy to try and figure out what you are doing wrong and what the fix is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not only will people here in the SAS Communities benefit from properly indented and formatted code, but in the long run you also will benefit from this, as errors are much more easily diagnosed.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 14:11:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-creating-extra-observations-and-variables/m-p/776974#M247123</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-28T14:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop creating extra observations and variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-creating-extra-observations-and-variables/m-p/776977#M247125</link>
      <description>&lt;P&gt;What do you think the OUTPUT statement does?&lt;BR /&gt;What effect do you think executing an OUTPUT statement every time through a DO loop would have on the number of observations written?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 14:15:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-creating-extra-observations-and-variables/m-p/776977#M247125</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-10-28T14:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop creating extra observations and variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-creating-extra-observations-and-variables/m-p/776978#M247126</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;&lt;FONT color="#0000FF"&gt;data&lt;/FONT&gt; perm.temp; 
 &lt;FONT color="#0000FF"&gt;set&lt;/FONT&gt; perm.mentalhealth; 
&lt;FONT color="#0000FF"&gt; array&lt;/FONT&gt; var_list[9] trouble_sleeping hurting_yourself interest depressed little_energy appetite feeling_bad &lt;BR /&gt; concentrating moving_slowly;
 &lt;FONT color="#0000FF"&gt;do&lt;/FONT&gt; i=&lt;FONT color="#339966"&gt;1&lt;/FONT&gt; to dim(var_list);
  VarName=vname(var_list(i));
  Outcome=var_list[i];
 &lt;FONT color="#0000FF"&gt; output&lt;/FONT&gt;;
&lt;FONT color="#0000FF"&gt;end&lt;/FONT&gt;;
 &lt;FONT color="#0000FF"&gt;array&lt;/FONT&gt; categorical[22]  gender age scalp_lesions postauricular erythema eyelid_involvement cheilitis flexural_erythema&lt;BR /&gt; xerosis neck_folds nipple_eczema keratosis palmar hand_eczema ichthyosis foot_eczema race education_final insurance &lt;BR /&gt; alopecia pityriasis pain_severeB;
 &lt;FONT color="#0000FF"&gt;do&lt;/FONT&gt; j=&lt;FONT color="#339966"&gt;1&lt;/FONT&gt; to dim(categorical);
  categorical_=vvalue(categorical(j));
 &lt;FONT color="#0000FF"&gt; output&lt;/FONT&gt;;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;end&lt;/FONT&gt;;
&lt;FONT color="#0000FF"&gt;array&lt;/FONT&gt; npredictors[9] SCORAD EASI BSA ADSI POEM_SCORE dlqi_score FIVED_SCORE RL_SCORE flare;
&lt;FONT color="#0000FF"&gt;do&lt;/FONT&gt; k=&lt;FONT color="#339966"&gt;1&lt;/FONT&gt; to dim(npredictors);
  npredictors_=vname(npredictors(k));
  &lt;FONT color="#0000FF"&gt;output&lt;/FONT&gt;;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;end&lt;/FONT&gt;;
&lt;FONT color="#0000FF"&gt;format&lt;/FONT&gt; Depression &lt;FONT color="#008000"&gt;Depressionn.&lt;/FONT&gt; Anxiety &lt;FONT color="#008000"&gt;Anxietyy.&lt;/FONT&gt; interest &lt;FONT color="#008000"&gt;interestt.&lt;/FONT&gt; depressed &lt;FONT color="#008000"&gt;_depressedd&lt;/FONT&gt;. trouble_sleeping &lt;FONT color="#008000"&gt;trouble_sleepingg&lt;/FONT&gt;. &lt;BR /&gt;little_energy &lt;FONT color="#008000"&gt;little_energyy.&lt;/FONT&gt; appetite&lt;FONT color="#008000"&gt; appetitee.&lt;/FONT&gt; feeling_bad &lt;FONT color="#008000"&gt;feeling_badd.&lt;/FONT&gt; concentrating &lt;FONT color="#008000"&gt;concentratingg.&lt;/FONT&gt; &lt;BR /&gt;moving_slowly &lt;FONT color="#008000"&gt;moving_slowlyy.&lt;/FONT&gt; hurting_yourself &lt;FONT color="#008000"&gt;hurting_yourselff.&lt;/FONT&gt; PHQ9_SCORE &lt;FONT color="#008000"&gt;PHQ9_SCORE_.&lt;/FONT&gt; PHQ2_SCORE&lt;FONT color="#008000"&gt; PHQ2_SCORE&lt;/FONT&gt;. &lt;BR /&gt;gender &lt;FONT color="#008000"&gt;gender&lt;/FONT&gt;. race &lt;FONT color="#008000"&gt;race.&lt;/FONT&gt; education_final &lt;FONT color="#008000"&gt;education.&lt;/FONT&gt; insurance &lt;FONT color="#008000"&gt;insurance&lt;/FONT&gt;. scalp_lesions &lt;FONT color="#008000"&gt;scalp_lesionss.&lt;/FONT&gt; postauricular&lt;FONT color="#008000"&gt; postauricularr&lt;/FONT&gt;. &lt;BR /&gt;erythema &lt;FONT color="#008000"&gt;erythemaa.&lt;/FONT&gt; eyelid_involvement&lt;FONT color="#008000"&gt; eyelid_involvementt. &lt;/FONT&gt;cheilitis &lt;FONT color="#008000"&gt;cheilitiss.&lt;/FONT&gt; flexural_erythema &lt;FONT color="#008000"&gt;flexural_erythemaa.&lt;/FONT&gt; &lt;BR /&gt;xerosis &lt;FONT color="#008000"&gt;xerosiss.&lt;/FONT&gt; neck_folds &lt;FONT color="#008000"&gt;neck_foldss.&lt;/FONT&gt; nipple_eczema &lt;FONT color="#008000"&gt;nipple_eczemaa.&lt;/FONT&gt; keratosis &lt;FONT color="#008000"&gt;keratosiss.&lt;/FONT&gt; palmar&lt;FONT color="#008000"&gt; palmarr.&lt;/FONT&gt; &lt;BR /&gt;hand_eczema &lt;FONT color="#008000"&gt;hand_eczemaa.&lt;/FONT&gt; ichthyosis &lt;FONT color="#008000"&gt;ichthyosiss.&lt;/FONT&gt; foot_eczema &lt;FONT color="#008000"&gt;foot_eczemaa.&lt;/FONT&gt; age &lt;FONT color="#008000"&gt;age_bin_.&lt;/FONT&gt; alopecia &lt;FONT color="#008000"&gt;alopeciaa.&lt;/FONT&gt; &lt;BR /&gt;pityriasis&lt;FONT color="#008000"&gt; pityriasiss.&lt;/FONT&gt; pain_severeB&lt;FONT color="#008000"&gt; painn.&lt;/FONT&gt; ;
&lt;FONT color="#0000FF"&gt;run&lt;/FONT&gt;; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Sorry about that. Does this help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 14:16:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-creating-extra-observations-and-variables/m-p/776978#M247126</guid>
      <dc:creator>393310</dc:creator>
      <dc:date>2021-10-28T14:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop creating extra observations and variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-creating-extra-observations-and-variables/m-p/776979#M247127</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/393310"&gt;@393310&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;&lt;FONT color="#0000FF"&gt;data&lt;/FONT&gt; perm.temp; 
 &lt;FONT color="#0000FF"&gt;set&lt;/FONT&gt; perm.mentalhealth; 
&lt;FONT color="#0000FF"&gt; array&lt;/FONT&gt; var_list[9] trouble_sleeping hurting_yourself interest depressed little_energy appetite feeling_bad &lt;BR /&gt; concentrating moving_slowly;
 &lt;FONT color="#0000FF"&gt;do&lt;/FONT&gt; i=&lt;FONT color="#339966"&gt;1&lt;/FONT&gt; to dim(var_list);
  VarName=vname(var_list(i));
  Outcome=var_list[i];
 &lt;FONT color="#0000FF"&gt; output&lt;/FONT&gt;;
&lt;FONT color="#0000FF"&gt;end&lt;/FONT&gt;;
 &lt;FONT color="#0000FF"&gt;array&lt;/FONT&gt; categorical[22]  gender age scalp_lesions postauricular erythema eyelid_involvement cheilitis flexural_erythema&lt;BR /&gt; xerosis neck_folds nipple_eczema keratosis palmar hand_eczema ichthyosis foot_eczema race education_final insurance &lt;BR /&gt; alopecia pityriasis pain_severeB;
 &lt;FONT color="#0000FF"&gt;do&lt;/FONT&gt; j=&lt;FONT color="#339966"&gt;1&lt;/FONT&gt; to dim(categorical);
  categorical_=vvalue(categorical(j));
 &lt;FONT color="#0000FF"&gt; output&lt;/FONT&gt;;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;end&lt;/FONT&gt;;
&lt;FONT color="#0000FF"&gt;array&lt;/FONT&gt; npredictors[9] SCORAD EASI BSA ADSI POEM_SCORE dlqi_score FIVED_SCORE RL_SCORE flare;
&lt;FONT color="#0000FF"&gt;do&lt;/FONT&gt; k=&lt;FONT color="#339966"&gt;1&lt;/FONT&gt; to dim(npredictors);
  npredictors_=vname(npredictors(k));
  &lt;FONT color="#0000FF"&gt;output&lt;/FONT&gt;;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;end&lt;/FONT&gt;;
&lt;FONT color="#0000FF"&gt;format&lt;/FONT&gt; Depression &lt;FONT color="#008000"&gt;Depressionn.&lt;/FONT&gt; Anxiety &lt;FONT color="#008000"&gt;Anxietyy.&lt;/FONT&gt; interest &lt;FONT color="#008000"&gt;interestt.&lt;/FONT&gt; depressed &lt;FONT color="#008000"&gt;_depressedd&lt;/FONT&gt;. trouble_sleeping &lt;FONT color="#008000"&gt;trouble_sleepingg&lt;/FONT&gt;. &lt;BR /&gt;little_energy &lt;FONT color="#008000"&gt;little_energyy.&lt;/FONT&gt; appetite&lt;FONT color="#008000"&gt; appetitee.&lt;/FONT&gt; feeling_bad &lt;FONT color="#008000"&gt;feeling_badd.&lt;/FONT&gt; concentrating &lt;FONT color="#008000"&gt;concentratingg.&lt;/FONT&gt; &lt;BR /&gt;moving_slowly &lt;FONT color="#008000"&gt;moving_slowlyy.&lt;/FONT&gt; hurting_yourself &lt;FONT color="#008000"&gt;hurting_yourselff.&lt;/FONT&gt; PHQ9_SCORE &lt;FONT color="#008000"&gt;PHQ9_SCORE_.&lt;/FONT&gt; PHQ2_SCORE&lt;FONT color="#008000"&gt; PHQ2_SCORE&lt;/FONT&gt;. &lt;BR /&gt;gender &lt;FONT color="#008000"&gt;gender&lt;/FONT&gt;. race &lt;FONT color="#008000"&gt;race.&lt;/FONT&gt; education_final &lt;FONT color="#008000"&gt;education.&lt;/FONT&gt; insurance &lt;FONT color="#008000"&gt;insurance&lt;/FONT&gt;. scalp_lesions &lt;FONT color="#008000"&gt;scalp_lesionss.&lt;/FONT&gt; postauricular&lt;FONT color="#008000"&gt; postauricularr&lt;/FONT&gt;. &lt;BR /&gt;erythema &lt;FONT color="#008000"&gt;erythemaa.&lt;/FONT&gt; eyelid_involvement&lt;FONT color="#008000"&gt; eyelid_involvementt. &lt;/FONT&gt;cheilitis &lt;FONT color="#008000"&gt;cheilitiss.&lt;/FONT&gt; flexural_erythema &lt;FONT color="#008000"&gt;flexural_erythemaa.&lt;/FONT&gt; &lt;BR /&gt;xerosis &lt;FONT color="#008000"&gt;xerosiss.&lt;/FONT&gt; neck_folds &lt;FONT color="#008000"&gt;neck_foldss.&lt;/FONT&gt; nipple_eczema &lt;FONT color="#008000"&gt;nipple_eczemaa.&lt;/FONT&gt; keratosis &lt;FONT color="#008000"&gt;keratosiss.&lt;/FONT&gt; palmar&lt;FONT color="#008000"&gt; palmarr.&lt;/FONT&gt; &lt;BR /&gt;hand_eczema &lt;FONT color="#008000"&gt;hand_eczemaa.&lt;/FONT&gt; ichthyosis &lt;FONT color="#008000"&gt;ichthyosiss.&lt;/FONT&gt; foot_eczema &lt;FONT color="#008000"&gt;foot_eczemaa.&lt;/FONT&gt; age &lt;FONT color="#008000"&gt;age_bin_.&lt;/FONT&gt; alopecia &lt;FONT color="#008000"&gt;alopeciaa.&lt;/FONT&gt; &lt;BR /&gt;pityriasis&lt;FONT color="#008000"&gt; pityriasiss.&lt;/FONT&gt; pain_severeB&lt;FONT color="#008000"&gt; painn.&lt;/FONT&gt; ;
&lt;FONT color="#0000FF"&gt;run&lt;/FONT&gt;; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Sorry about that. Does this help?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The point of formatting and indenting is to make things VISUALLY obvious. So I prefer to see four spaces — or one tab — rather then one space when you indent. And if it is a second indent, then it would be eight spaces — or two tabs — when you indent. Your use of one space isn't particularly visually obvious to me (and I wonder if it is visually obvious to you). I would also want to see the END command left aligned with the corresponding DO command.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So no, that doesn't help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Again, my point is that YOU will benefit from putting a little extra effort in to formatting your code well, this makes coding problems more easy to identify. Such formatting also benefits YOU because those of us here in the SAS Communities will find your code easier to debug.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, I think&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;has identified the problem correctly.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 14:55:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-creating-extra-observations-and-variables/m-p/776979#M247127</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-28T14:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop creating extra observations and variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-creating-extra-observations-and-variables/m-p/776980#M247128</link>
      <description>&lt;P&gt;If you want the new dataset to only have some of the variables then use a KEEP statement to list the variables you want. Or use a DROP statement to list the variables you don't want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I don't understand what structure you are trying to create.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to convert wide to tall then go all the way.&amp;nbsp; Your new dataset probably needs just a few variables (but not the ones your code is making).&lt;/P&gt;
&lt;P&gt;1) Some type of ID that indicates the original observation.&amp;nbsp; If your data does have one (or more) variable that uniquely idenitify the rows then create one.&lt;/P&gt;
&lt;P&gt;2) A variable to indicate which of the three types.&lt;/P&gt;
&lt;P&gt;3) A variable to include the variable name&lt;/P&gt;
&lt;P&gt;4) A variable to include the value.&amp;nbsp; Since you are mixing types this will need to a character variable.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 14:31:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-creating-extra-observations-and-variables/m-p/776980#M247128</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-10-28T14:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop creating extra observations and variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-creating-extra-observations-and-variables/m-p/777022#M247152</link>
      <description>&lt;P&gt;You have three arrays, with 9, 22 and 9 members. You loop over all three arrays separately, which merans that you have 40 loops done overall. Since every DO loop contains an OUTPUT, you get 40 observations in the new dataset for every observation in the old dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You create these new variables:&lt;/P&gt;
&lt;P&gt;i, j, k (loop indexes)&lt;/P&gt;
&lt;P&gt;varname, outcome (coded in the first loop)&lt;/P&gt;
&lt;P&gt;categorical_ (in the second loop)&lt;/P&gt;
&lt;P&gt;npredictors_(in the third loop)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This are 7 additional variables. 94 + 7 = 101.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 16:01:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-creating-extra-observations-and-variables/m-p/777022#M247152</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-28T16:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop creating extra observations and variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-creating-extra-observations-and-variables/m-p/777137#M247201</link>
      <description>Thank you so much for breaking that down, I am new to sas and coding so I really appreciate the help.</description>
      <pubDate>Thu, 28 Oct 2021 22:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-creating-extra-observations-and-variables/m-p/777137#M247201</guid>
      <dc:creator>393310</dc:creator>
      <dc:date>2021-10-28T22:49:35Z</dc:date>
    </item>
  </channel>
</rss>

