<?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: I want to select alternate columns in my data set. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-select-alternate-columns-in-my-data-set/m-p/927559#M365006</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436607"&gt;@Discaboota&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I want columns as following :-&lt;BR /&gt;LOAN_NO, FINAL_STATUS_05MAY24, FINAL_STATUS_06MAY24, FINAL_STATUS_07MAY24,&lt;BR /&gt;FINAL_STATUS_08MAY24,&lt;BR /&gt;FINAL_STATUS_09MAY24,&lt;BR /&gt;FINAL_STATUS_10MAY24,&lt;BR /&gt;and so on...&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That seems trivial to me and has NOTHING to with the ORDER of the variables in the dataset, just the NAME of the variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  keep loan_no final_status: ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 May 2024 16:16:29 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-05-08T16:16:29Z</dc:date>
    <item>
      <title>I want to select alternate columns in my data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-select-alternate-columns-in-my-data-set/m-p/927300#M364943</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA ALT;
    SET RCA.CLOSING_STATUS_TEST;
    ARRAY COLS[*] _CHARACTER_; 
    ARRAY COLS_[*] _CHARACTER_;
    DO I = 1 TO DIM(COLS);
        IF MOD(I, 2) = 1 THEN 
            COLS_[(I+1)/2] = COLS[I]; 
    END;
    DROP I;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hi, I have been trying to select the alternate columns. &lt;BR /&gt;If I am using this code then my third column's data shifts to second column and second's values are disappearing.&amp;nbsp;&lt;BR /&gt;I want to select alternate columns from my data set and my column names are in following:&lt;BR /&gt;&lt;SPAN&gt;LOAN_NO,&amp;nbsp;PRODUCT,&amp;nbsp;FINAL_STATUS_05MAY24,DUE_N_TAG_05MAY24,&amp;nbsp;FINAL_STATUS_06MAY24,DUE_N_TAG_06MAY24,&amp;nbsp;FINAL_STATUS_07MAY24,DUE_N_TAG_07MAY24,... and so on.&lt;BR /&gt;&lt;/SPAN&gt;I want to create a table selecting columns:-&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;LOAN_NO, FINAL_STATUS_05MAY24, FINAL_STATUS_06MAY24, FINAL_STATUS_07MAY24... and so on.&lt;BR /&gt;If there is any alternate approach for making the selection, please advise me or please help with the given array code.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2024 13:13:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-select-alternate-columns-in-my-data-set/m-p/927300#M364943</guid>
      <dc:creator>Discaboota</dc:creator>
      <dc:date>2024-05-07T13:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: I want to select alternate columns in my data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-select-alternate-columns-in-my-data-set/m-p/927303#M364946</link>
      <description>&lt;P&gt;Help me understand, please -- you want the following columns in your output?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;LOAN_NO, PRODUCT, FINAL_STATUS_05MAY24,DUE_N_TAG_05MAY24, FINAL_STATUS_06MAY24,DUE_N_TAG_06MAY24, FINAL_STATUS_07MAY24,DUE_N_TAG_07MAY24&lt;/PRE&gt;
&lt;P&gt;Is there any way you could show us what you want at the end?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2024 13:20:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-select-alternate-columns-in-my-data-set/m-p/927303#M364946</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2024-05-07T13:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: I want to select alternate columns in my data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-select-alternate-columns-in-my-data-set/m-p/927305#M364947</link>
      <description>I want columns as following :-&lt;BR /&gt;LOAN_NO,  FINAL_STATUS_05MAY24, FINAL_STATUS_06MAY24, FINAL_STATUS_07MAY24,&lt;BR /&gt;FINAL_STATUS_08MAY24,&lt;BR /&gt;FINAL_STATUS_09MAY24,&lt;BR /&gt;FINAL_STATUS_10MAY24,&lt;BR /&gt;and so on...</description>
      <pubDate>Tue, 07 May 2024 13:33:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-select-alternate-columns-in-my-data-set/m-p/927305#M364947</guid>
      <dc:creator>Discaboota</dc:creator>
      <dc:date>2024-05-07T13:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: I want to select alternate columns in my data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-select-alternate-columns-in-my-data-set/m-p/927307#M364948</link>
      <description>&lt;P&gt;How many dates do you have included in this report? Is this run daily or weekly? Monthly?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The dates would need to be created dynamically depending on the above.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can't tell if this is a retroactive lookback (e.g., this week looks at last week, etc.) to create those date variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2024 13:36:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-select-alternate-columns-in-my-data-set/m-p/927307#M364948</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2024-05-07T13:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: I want to select alternate columns in my data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-select-alternate-columns-in-my-data-set/m-p/927314#M364952</link>
      <description>&lt;P&gt;One of the problems that you may be encountering is the way the variables are presented using the _CHARACTER_ in a list.&lt;/P&gt;
&lt;P&gt;You might run this code:&lt;/P&gt;
&lt;PRE&gt;DATA _null_;
    SET RCA.CLOSING_STATUS_TEST (obs=1);
    ARRAY COLS[*] _CHARACTER_; 
    DO I = 1 TO DIM(COLS);
       temp= vname(cols[i]);
       put i= temp=  ;

    END;
RUN;&lt;/PRE&gt;
&lt;P&gt;to show the order of the variables actually processed. May get a surprise. The VNAME function returns the name of a variable used in an array in this case. The log will show something like (using SASHELP.CARS as input):&lt;/P&gt;
&lt;PRE&gt;I=1 temp=Make
I=2 temp=Model
I=3 temp=Type
I=4 temp=Origin
I=5 temp=DriveTrain
&lt;/PRE&gt;
&lt;P&gt;Unless all of your _CHARACTER_ variables are defined with the exact same length you general approach was very likely to have truncated values somewhere when you assign a longer value to a variable with a shorter length.&lt;/P&gt;
&lt;P&gt;To select the Final_status variables:&lt;/P&gt;
&lt;PRE&gt;data want;
   set rca.closing_status_test;
   keep loan_no Product Final_Status: ;
run;&lt;/PRE&gt;
&lt;P&gt;The colon immediately following part of a variable name is one of the list building tools in SAS. It means use all the variables whose names start with Final_status in this case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Variable names like FINAL_STATUS_05MAY24,DUE_N_TAG_05MAY24 often indicate someone is attempting to use a spreadsheet type of thinking, and typically a source of data, that is poor for general SAS processing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Better would be to restructure your data so that you have, in addition to identification variables something that looks like FINAL_STATUS, DUE_N_TAG, and a Date variable with value of 05May2024 (and 06 May, 07 May etc) with one observation per date.&lt;/P&gt;
&lt;P&gt;Then you would select the observations for analysis or reporting based on the range of the date values of interest.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like (pretty obviously untested as I don't have your data):&lt;/P&gt;
&lt;PRE&gt;data reshaped;
   set  rca.closing_status_test;
   array f (*) FINAL_STATUS_05MAY24 FINAL_STATUS_06MAY24 FINAL_STATUS_07MAY24;
   array d (*) DUE_N_TAG_05MAY24    DUE_N_TAG_06MAY24    DUE_N_TAG_07MAY24;
   do i= 1 to dim(f);
      FinalStatus= f[i];
      Due = d[i];
      date = input(substr(vname(f[i]),14),date7.);
      output;
   end;
   format date date9.;
   keep Loan_no Product &amp;lt;other variable as needed&amp;gt; FinalStatus Due Date;
run;&lt;/PRE&gt;
&lt;P&gt;Then once you have such a data set you would select using something like:&lt;/P&gt;
&lt;PRE&gt;Proc print data=reshaped;
   where date ge '06MAY2024'd;
run;

/*or */

Proc print data=reshaped;
   where '06May2024'd le date le '07MAY2024'd;
run;
&lt;/PRE&gt;
&lt;P&gt;For the few procedures that don't honor a Where statement you can use where in a data set option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest actually rereading the data to avoid such structure and variable names if possible.&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2024 13:56:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-select-alternate-columns-in-my-data-set/m-p/927314#M364952</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-05-07T13:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: I want to select alternate columns in my data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-select-alternate-columns-in-my-data-set/m-p/927386#M364981</link>
      <description>The dates will be increasing from now on and if I need to call the query a month from now to select the column:&lt;BR /&gt;LOAN_NO, FINAL_STATUS_05MAY24, FINAL_STATUS_06MAY24, FINAL_STATUS_07MAY24,&lt;BR /&gt;FINAL_STATUS_08MAY24,&lt;BR /&gt;FINAL_STATUS_09MAY24,&lt;BR /&gt;FINAL_STATUS_10MAY24,&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;FINAL_STATUS_31MAY24.&lt;BR /&gt;&lt;BR /&gt;In this, all I want is to select column by sequence 1,3,5,7,9,...,n&lt;BR /&gt; till the date of requirement which could be n .</description>
      <pubDate>Wed, 08 May 2024 04:50:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-select-alternate-columns-in-my-data-set/m-p/927386#M364981</guid>
      <dc:creator>Discaboota</dc:creator>
      <dc:date>2024-05-08T04:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: I want to select alternate columns in my data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-select-alternate-columns-in-my-data-set/m-p/927387#M364982</link>
      <description>&lt;P&gt;You &lt;STRONG&gt;really, really&lt;/STRONG&gt; should consider reshaping your data as suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your table contained LOAN_NO, FINAL_STATUS_DATE and FINAL_STATUS (a row per loan per date), you would be adding a row for each new date, not creating a new column for each new date. This would simplify your logic a lot and most like improve processing efficiency as well.&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 05:03:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-select-alternate-columns-in-my-data-set/m-p/927387#M364982</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2024-05-08T05:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: I want to select alternate columns in my data set.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-select-alternate-columns-in-my-data-set/m-p/927559#M365006</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436607"&gt;@Discaboota&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I want columns as following :-&lt;BR /&gt;LOAN_NO, FINAL_STATUS_05MAY24, FINAL_STATUS_06MAY24, FINAL_STATUS_07MAY24,&lt;BR /&gt;FINAL_STATUS_08MAY24,&lt;BR /&gt;FINAL_STATUS_09MAY24,&lt;BR /&gt;FINAL_STATUS_10MAY24,&lt;BR /&gt;and so on...&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That seems trivial to me and has NOTHING to with the ORDER of the variables in the dataset, just the NAME of the variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  keep loan_no final_status: ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 16:16:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-select-alternate-columns-in-my-data-set/m-p/927559#M365006</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-05-08T16:16:29Z</dc:date>
    </item>
  </channel>
</rss>

