<?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: creating multiple permanent data sets in one data step based on category of variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/creating-multiple-permanent-data-sets-in-one-data-step-based-on/m-p/736894#M229671</link>
    <description>&lt;P&gt;I don't know who is teaching you but generally SAS uses a LIBRARY.DATASETNAME notation so that once a library is created you reference datasets as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;mylib.somename instead of incorporating paths and such making very hard to type and spell names correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have to assume this an assignment that is forcing bad programming practices.&lt;/P&gt;
&lt;P&gt;In a data step you need to use an explicit output statement to write records to a specific data set unless you really enjoy writing ugly code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF you are going to do such it would be a good idea to name the datasets so that&amp;nbsp; the name means something.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'll show one way to do two data sets. It should be easy to add the rest.&lt;/P&gt;
&lt;PRE&gt;data At_home health;
   set student;
   if mjob='At_home' then output At_home;
   if mjob='Health' then output Health;
run;&lt;/PRE&gt;
&lt;P&gt;Without a library name these will write to the WORK library. This assumes the existing data is in the work library and named student. I am not sure what your actual data set name is because what you show is almost never used.&lt;/P&gt;
&lt;P&gt;If you are using data set names like 'E:\SAS HW\P_student' the name must be referenced as 'E:\SAS HW\P_student'n . The N immediately following the quote tells SAS you are using it as a name of something. Context would tell SAS whether it is a data set, such as appearing on a SET statement or part of a "data='some name'n" construct, or a variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your "instructor" hasn't covered libraries yet I foresee lots of troubles actually using the instruction. Libraries should be covered in the first hour or so of any reasonably good instruction program. Adding the name of library you made to the names makes them "permanent" data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Apr 2021 00:32:24 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-04-26T00:32:24Z</dc:date>
    <item>
      <title>creating multiple permanent data sets in one data step based on category of variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-multiple-permanent-data-sets-in-one-data-step-based-on/m-p/736885#M229668</link>
      <description>&lt;P&gt;Hi y'all! I need to answer this problem:&lt;/P&gt;&lt;P&gt;Create five permanent data sets in one data step base on the categories of variable &lt;STRONG&gt;Mjob. &lt;/STRONG&gt;(i.e. one data set contains Mjob=’&lt;STRONG&gt; At_home&lt;/STRONG&gt;’, one contains Mjob=’Health’, …..)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TITLE 'Problem 2 (5)';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA 'E:\SAS HW\P_student2' (KEEP=Mjob WHERE Mjob='At_home') 'E:\SAS HW\P_student3' (KEEP=Mjob WHERE Mjob='Health') 'E:\SAS HW\P_student4' (KEEP=Mjob WHERE Mjob='Other') 'E:\SAS HW\P_student5'&lt;BR /&gt;(KEEP=Mjob WHERE Mjob='Services') 'E:\SAS HW\P_student6' (KEEP=Mjob WHERE Mjob='Teacher');&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;SET 'E:\SAS HW\P_student';&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not sure how to denote the category of the variable Mjob that I want to show up when I print observations (the WHERE statement does not work). Any help would be appreciated thank you!&lt;/P&gt;</description>
      <pubDate>Sun, 25 Apr 2021 21:38:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-multiple-permanent-data-sets-in-one-data-step-based-on/m-p/736885#M229668</guid>
      <dc:creator>kariarchie</dc:creator>
      <dc:date>2021-04-25T21:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: creating multiple permanent data sets in one data step based on category of variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-multiple-permanent-data-sets-in-one-data-step-based-on/m-p/736894#M229671</link>
      <description>&lt;P&gt;I don't know who is teaching you but generally SAS uses a LIBRARY.DATASETNAME notation so that once a library is created you reference datasets as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;mylib.somename instead of incorporating paths and such making very hard to type and spell names correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have to assume this an assignment that is forcing bad programming practices.&lt;/P&gt;
&lt;P&gt;In a data step you need to use an explicit output statement to write records to a specific data set unless you really enjoy writing ugly code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF you are going to do such it would be a good idea to name the datasets so that&amp;nbsp; the name means something.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'll show one way to do two data sets. It should be easy to add the rest.&lt;/P&gt;
&lt;PRE&gt;data At_home health;
   set student;
   if mjob='At_home' then output At_home;
   if mjob='Health' then output Health;
run;&lt;/PRE&gt;
&lt;P&gt;Without a library name these will write to the WORK library. This assumes the existing data is in the work library and named student. I am not sure what your actual data set name is because what you show is almost never used.&lt;/P&gt;
&lt;P&gt;If you are using data set names like 'E:\SAS HW\P_student' the name must be referenced as 'E:\SAS HW\P_student'n . The N immediately following the quote tells SAS you are using it as a name of something. Context would tell SAS whether it is a data set, such as appearing on a SET statement or part of a "data='some name'n" construct, or a variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your "instructor" hasn't covered libraries yet I foresee lots of troubles actually using the instruction. Libraries should be covered in the first hour or so of any reasonably good instruction program. Adding the name of library you made to the names makes them "permanent" data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 00:32:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-multiple-permanent-data-sets-in-one-data-step-based-on/m-p/736894#M229671</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-26T00:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: creating multiple permanent data sets in one data step based on category of variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-multiple-permanent-data-sets-in-one-data-step-based-on/m-p/736903#M229678</link>
      <description>&lt;P&gt;Your program should produce 5 sas data sets, each with an exclusive value of MJOB.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I don't understand is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I am not sure how to denote the category of the variable Mjob that I want to show up when I print observations (the WHERE statement does not work).&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Saying "the WHERE statement does not work" does not work in getting a helpful response.&amp;nbsp; Show an example, describe what you expected, and what you got.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What I think you mean is that you probably got a log message that you didn't report to us.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You should change the syntax of your where condition to&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;(KEEP=Mjob WHERE=(Mjob='Health'))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;This is using where as a &lt;EM&gt;&lt;STRONG&gt;data set name parameter&lt;/STRONG&gt;&lt;/EM&gt;, which is not the same syntax as a where &lt;EM&gt;&lt;STRONG&gt;statement.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 03:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-multiple-permanent-data-sets-in-one-data-step-based-on/m-p/736903#M229678</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-04-26T03:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: creating multiple permanent data sets in one data step based on category of variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-multiple-permanent-data-sets-in-one-data-step-based-on/m-p/736907#M229681</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; : it seems like someone thought, that the whole concept of libraries is to difficult, so it is to skipped in courses and the participants are taught to use the unreadable full-path-syntax instead. Maybe this was initiated by the same person thinking that it is a good idea to teach macro-programming in the first course.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 05:37:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-multiple-permanent-data-sets-in-one-data-step-based-on/m-p/736907#M229681</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-04-26T05:37:10Z</dc:date>
    </item>
  </channel>
</rss>

