<?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: DROP CERTAIN VARIABLES in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938361#M42158</link>
    <description>&lt;P&gt;Expecting a variable name after %LET.&lt;BR /&gt;ERROR: Symbolic variable name VARLIST. must contain only letters, digits, and underscores.&lt;BR /&gt;ERROR: The macro ROLLYR will stop executing. Do I have to change variable name?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Aug 2024 14:02:56 GMT</pubDate>
    <dc:creator>stella7</dc:creator>
    <dc:date>2024-08-06T14:02:56Z</dc:date>
    <item>
      <title>DROP CERTAIN VARIABLES</title>
      <link>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938302#M42152</link>
      <description>&lt;P&gt;%LET StartYr=2010;&lt;/P&gt;&lt;P&gt;%LET EVENTYr=2023;&lt;/P&gt;&lt;P&gt;%MACRO TESTyr(EventYr, StartYr);&lt;/P&gt;&lt;P&gt;%do year = &amp;amp;StartYr %to &amp;amp;EventYr;&lt;/P&gt;&lt;P&gt;data&amp;nbsp; .years2;&lt;BR /&gt;%let drop_vars = A&amp;amp;year._%eval(&amp;amp;year-2);&amp;nbsp; /******** Variable names are A2008_2006, A2009_2007........ A2023_2021 ***************/&lt;BR /&gt;data&amp;nbsp; .years2;&lt;BR /&gt;set&amp;nbsp; DATASET (drop=%drop_vars); %end;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; dyear = &amp;amp;year;&amp;nbsp; &amp;nbsp; /***** other NEW variable, DYEAR in dataset *********/&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;%TestYr(&amp;amp;startyr, %eventyr);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi, set dataset (drop A2008_2006) WORKS WELL, but how do I&amp;nbsp; drop multiple columns in macro variable list?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2024 20:37:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938302#M42152</guid>
      <dc:creator>stella7</dc:creator>
      <dc:date>2024-08-05T20:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: DROP CERTAIN VARIABLES</title>
      <link>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938304#M42153</link>
      <description>&lt;P&gt;This code shows one way to place all the names into a single variable:&lt;/P&gt;
&lt;PRE&gt;%LET StartYr=2010;

%LET EVENTYr=2023;
%let varlist=;
%macro testyr(EventYr, StartYr);
%do year = &amp;amp;StartYr %to &amp;amp;EventYr;
   %let varlist.= &amp;amp;varlist. A&amp;amp;year._%eval(&amp;amp;year.-2);  
%end;

%put &amp;amp;varlist;

%mend;

%testyr(&amp;amp;eventyr. , &amp;amp;startyr.);&lt;/PRE&gt;
&lt;P&gt;Use&amp;nbsp; &amp;amp;varlist. anywhere following the definition where you want a space-delimited list of variable names. such as&amp;nbsp;&amp;nbsp; (drop=&amp;amp;varlist. ) as a data set option. (&lt;STRONG&gt;NOT &lt;/STRONG&gt;%varlist)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/465057"&gt;@stella7&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;%LET StartYr=2010;&lt;/P&gt;
&lt;P&gt;%LET EVENTYr=2023;&lt;/P&gt;
&lt;P&gt;%MACRO TESTyr(EventYr, StartYr);&lt;/P&gt;
&lt;P&gt;%do year = &amp;amp;StartYr %to &amp;amp;EventYr;&lt;/P&gt;
&lt;P&gt;data&amp;nbsp; .years2;&lt;BR /&gt;%let drop_vars = A&amp;amp;year._%eval(&amp;amp;year-2);&amp;nbsp; /******** Variable names are A2008_2006, A2009_2007........ A2023_2021 ***************/&lt;BR /&gt;data&amp;nbsp; .years2;&lt;BR /&gt;set&amp;nbsp; DATASET (drop=%drop_vars); %end;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; dyear = &amp;amp;year;&amp;nbsp; &amp;nbsp; /***** other NEW variable, DYEAR in dataset *********/&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;/P&gt;
&lt;P&gt;%TestYr(&amp;amp;startyr, %eventyr);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi, set dataset (drop A2008_2006) WORKS WELL, but how do I&amp;nbsp; drop multiple columns in macro variable list?&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2024 21:09:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938304#M42153</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-05T21:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: DROP CERTAIN VARIABLES</title>
      <link>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938309#M42154</link>
      <description>&lt;P&gt;Either put ALL of the variable names into VARLIST.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro testyr(eventyr, startyr);
%local year varlist;
%do year = &amp;amp;startyr %to &amp;amp;eventyr;
  %let varlist=&amp;amp;varlist a&amp;amp;year._%eval(&amp;amp;year-2);
%end;
data years2;
  set dataset;
  drop &amp;amp;varlist;
run;
%mend testyr;
%testyr(startyr=2010,eventyr=2023)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or move the %DO loop into the middle of the DROP statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro testyr(eventyr, startyr);
%local year ;
data years2;
  set dataset;
  drop 
%do year = &amp;amp;startyr %to &amp;amp;eventyr;
  a&amp;amp;year._%eval(&amp;amp;year-2)
%end;
  ;
run;
%mend;
%testyr(startyr=2010,eventyr=2023)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;But this statement in your original data step is a problem:&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   dyear = &amp;amp;year;  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The macro variable YEAR will have many different values, from STARTYR to EVENTYR.&amp;nbsp; Which one to you want to store into the dataset variable DYEAR?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2024 01:52:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938309#M42154</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-06T01:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: DROP CERTAIN VARIABLES</title>
      <link>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938325#M42157</link>
      <description>&lt;P&gt;You have data (time periods) in structure (variable names).&lt;/P&gt;
&lt;P&gt;Transpose your dataset to long, and extract the start and end years into numeric variables. This will make handling your data&amp;nbsp;&lt;U&gt;much&lt;/U&gt; easier.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=long (rename=(col1=a));
by /* whatever identifies your individual observations */;
var a:;
run;

data want;
set long;
start = input(scan(substr(_name_,2),1,"_"),4.);
end = input(scan(_name_,2,"_"),4.);
drop _name_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Aug 2024 08:17:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938325#M42157</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-08-06T08:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: DROP CERTAIN VARIABLES</title>
      <link>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938361#M42158</link>
      <description>&lt;P&gt;Expecting a variable name after %LET.&lt;BR /&gt;ERROR: Symbolic variable name VARLIST. must contain only letters, digits, and underscores.&lt;BR /&gt;ERROR: The macro ROLLYR will stop executing. Do I have to change variable name?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2024 14:02:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938361#M42158</guid>
      <dc:creator>stella7</dc:creator>
      <dc:date>2024-08-06T14:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: DROP CERTAIN VARIABLES</title>
      <link>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938362#M42159</link>
      <description>&lt;P&gt;year comes from the other macro dataset test_temp. I can rename from year to yrs.&lt;/P&gt;&lt;P&gt;However, it has the same errors after I changed the.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data&amp;nbsp; testyrs; set test_temp;&lt;BR /&gt;%do year = &amp;amp;StartYr %to &amp;amp;EventYr;&lt;BR /&gt;if R&amp;amp;year_%eval(&amp;amp;year-2) ne . then year=&amp;amp;year;&amp;nbsp; ====&amp;gt;&lt;FONT face="arial black,avant garde"&gt; R&amp;amp;yrs... &amp;amp;yrs ne. then year1=&amp;amp;yrs;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;%end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2024 14:12:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938362#M42159</guid>
      <dc:creator>stella7</dc:creator>
      <dc:date>2024-08-06T14:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: DROP CERTAIN VARIABLES</title>
      <link>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938363#M42160</link>
      <description>Not R but A</description>
      <pubDate>Tue, 06 Aug 2024 14:15:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938363#M42160</guid>
      <dc:creator>stella7</dc:creator>
      <dc:date>2024-08-06T14:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: DROP CERTAIN VARIABLES</title>
      <link>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938364#M42161</link>
      <description>NOT ROLLYR BUT TESTYR</description>
      <pubDate>Tue, 06 Aug 2024 14:16:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938364#M42161</guid>
      <dc:creator>stella7</dc:creator>
      <dc:date>2024-08-06T14:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: DROP CERTAIN VARIABLES</title>
      <link>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938372#M42162</link>
      <description>&lt;P&gt;Saying something has errors but not showing the error is not helpful.&lt;/P&gt;
&lt;P&gt;Please, Copy the text from the log including the code that generates the error message(s) along with the errors and post into a text box opened on the forum with the &amp;lt;/&amp;gt; icon that appears above the main message window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The text box prevents the forum software from reformatting pasted text and sets the log apart from the discussion.&lt;/P&gt;
&lt;P&gt;When dealing with MACRO code it is a good idea to run the code with OPTIONS MPRINT; set before running the macro so more details of the generated code are shown in the log. Such as&lt;/P&gt;
&lt;PRE&gt;options mprint;

%TestYr(&amp;amp;startyr, %eventyr);

options nomprint;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: Data sets are data sets. There is no such thing as a "macro data set" as used in your phrase "other macro dataset test_temp". The name of a data set may be stored in a macro variable but it is still a data set (or View).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, this is the first mention of the data set temp_test. Which makes it doubly important to post the code involved.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2024 15:04:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938372#M42162</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-06T15:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: DROP CERTAIN VARIABLES</title>
      <link>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938375#M42163</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/465057"&gt;@stella7&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;year comes from the other macro dataset test_temp. I can rename from year to yrs.&lt;/P&gt;
&lt;P&gt;However, it has the same errors after I changed the.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data&amp;nbsp; testyrs; set test_temp;&lt;BR /&gt;%do year = &amp;amp;StartYr %to &amp;amp;EventYr;&lt;BR /&gt;if R&amp;amp;year_%eval(&amp;amp;year-2) ne . then year=&amp;amp;year;&amp;nbsp; ====&amp;gt;&lt;FONT face="arial black,avant garde"&gt; R&amp;amp;yrs... &amp;amp;yrs ne. then year1=&amp;amp;yrs;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;%end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;"macro dataset"&amp;nbsp; What does that mean?&amp;nbsp;Did you mean "other dataset"?&amp;nbsp; What other dataset?&amp;nbsp; You only mentioned one input dataset in your original question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before trying to use macro code to generate code it helps to first write out the actual code you want to run.&amp;nbsp; Then you can work on using the macro language to help you generate that code.&amp;nbsp; So what code would you want to run for your example range of years?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2024 15:18:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938375#M42163</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-06T15:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: DROP CERTAIN VARIABLES</title>
      <link>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938379#M42164</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/465057"&gt;@stella7&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Expecting a variable name after %LET.&lt;BR /&gt;ERROR: Symbolic variable name VARLIST. must contain only letters, digits, and underscores.&lt;BR /&gt;ERROR: The macro ROLLYR will stop executing. Do I have to change variable name?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Variable names cannot have a period in them.&amp;nbsp; If the period is not there then there is some other invisible character.&amp;nbsp; Just retype the line.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2024 15:31:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/DROP-CERTAIN-VARIABLES/m-p/938379#M42164</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-06T15:31:39Z</dc:date>
    </item>
  </channel>
</rss>

