<?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: Sorting Data Help in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sorting-Data-Help/m-p/503916#M134764</link>
    <description>&lt;P&gt;Here is the data. Yes this is the one of the task in HW. If you can help me that would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Oct 2018 21:21:04 GMT</pubDate>
    <dc:creator>jk101564</dc:creator>
    <dc:date>2018-10-12T21:21:04Z</dc:date>
    <item>
      <title>Sorting Data Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-Data-Help/m-p/503605#M134607</link>
      <description>&lt;P&gt;Hello, I am trying to do the following task but since i am new to SAS, I need some help. If anyone can help me out.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Generate&amp;nbsp;&lt;SPAN&gt;20 observations for the total population estimate of females that worked full-time. Also, i need to create a variable that contains the maximum earning. For example, for label $2,500 to $4,999, the variable would include value 4,999. Also, i need to&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;store&amp;nbsp;this data in a raw data file. Sort the data from highest amount earned to the lowest amount earned. Store this sorted data in a second raw data file. Perform another sort to order the data from highest population number to lowest population number. Store this sorted data in a third raw data file. Keep the two related data variables associated so that after each sort the amount earned is associated with the population number or the number of people that earned that amount.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code i have so far.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC IMPORT DATAFILE='file.csv' replace DBMS= csv OUT=file.population
run;

Data Fem; 
SET population; 
Where Gender = 'Female' AND Status ='Fulltime';
run;

/*Creates a raw 'txt' file to hold the data*/
DATA _NULL_
SET Fem;
FILE PRINT 'T0.txt';
PUT SEX $ POPULATION Salary_Low Salary_High;
run;

/* Sorts the data by Salary_High in descending order (highest to lowest salary */
PROC SORT data = Fem; 
BY DESCENDING Salary_High; 
run;

/*Creates a raw 'txt' file to hold the data */
DATA _NULL_ 
SET Fem; 
FILE PRINT 'T1.txt';
PUT SEX $ POPULATION Salary_Low Salary_High;
run;

/* Sorts the data from Highest to lowest population #'s per salary*/
PROC SORT data = Fem;
BY DESCENDING Population;
run;

/*Creates a raw 'txt' file to hold the data*/
DATA _NULL_
SET Fem;
FILE PRINT 'T2.txt'; 
PUT SEX $ POPULATION Salary_Low Salary_High;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 00:23:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-Data-Help/m-p/503605#M134607</guid>
      <dc:creator>jk101564</dc:creator>
      <dc:date>2018-10-12T00:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Data Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-Data-Help/m-p/503767#M134669</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/238897"&gt;@jk101564&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello, I am trying to do the following task but since i am new to SAS, I need some help. If anyone can help me out.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Generate&amp;nbsp;&lt;SPAN&gt;20 observations for the total population estimate of females that worked full-time. Also, i need to create a variable that contains the maximum earning. For example, for label $2,500 to $4,999, the variable would include value 4,999. Also, i need to&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;store&amp;nbsp;this data in a raw data file. Sort the data from highest amount earned to the lowest amount earned. Store this sorted data in a second raw data file. Perform another sort to order the data from highest population number to lowest population number. Store this sorted data in a third raw data file. Keep the two related data variables associated so that after each sort the amount earned is associated with the population number or the number of people that earned that amount.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the code i have so far.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC IMPORT DATAFILE='file.csv' replace DBMS= csv OUT=file.population
run;

Data Fem; 
SET population; 
Where Gender = 'Female' AND Status ='Fulltime';
run;

/*Creates a raw 'txt' file to hold the data*/
DATA _NULL_
SET Fem;
FILE PRINT 'T0.txt';
PUT SEX $ POPULATION Salary_Low Salary_High;
run;

/* Sorts the data by Salary_High in descending order (highest to lowest salary */
PROC SORT data = Fem; 
BY DESCENDING Salary_High; 
run;

/*Creates a raw 'txt' file to hold the data */
DATA _NULL_ 
SET Fem; 
FILE PRINT 'T1.txt';
PUT SEX $ POPULATION Salary_Low Salary_High;
run;

/* Sorts the data from Highest to lowest population #'s per salary*/
PROC SORT data = Fem;
BY DESCENDING Population;
run;

/*Creates a raw 'txt' file to hold the data*/
DATA _NULL_
SET Fem;
FILE PRINT 'T2.txt'; 
PUT SEX $ POPULATION Salary_Low Salary_High;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Some example data and the actual desired result for a few records will help. It is not clear from your description whether the desired output is actually&amp;nbsp;a SAS data set, a text file, multiple SAS datasets, multiple text files or specifically what any of those would look like.&lt;/P&gt;
&lt;P&gt;Is the process one that was given to you that you must follow or what you think is an approach to a solution?&lt;/P&gt;
&lt;P&gt;Also, this sort of sounds like homework. Is that the case?&lt;/P&gt;
&lt;P&gt;If the objective is to only put the first value into the text files then the data set option OBS controls how many records are processed by the data step.&lt;/P&gt;
&lt;PRE&gt;DATA _NULL_
SET Fem (obs=1);
FILE PRINT 'T0.txt';
PUT SEX $ POPULATION Salary_Low Salary_High;
run;

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS has several ways of identifying the records associated with the maximum (or minimum)&amp;nbsp;value of something. Here is an example using a data set that should have been included in your SAS installation.&lt;/P&gt;
&lt;PRE&gt;proc means data=sashelp.class nway;
   class sex;
   id name;
   var height;
   output out=work.classsummary drop=(_type_ _freq_)
          max=maxheight maxid=maxname
   ;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Oct 2018 15:57:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-Data-Help/m-p/503767#M134669</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-12T15:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Data Help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-Data-Help/m-p/503916#M134764</link>
      <description>&lt;P&gt;Here is the data. Yes this is the one of the task in HW. If you can help me that would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 21:21:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-Data-Help/m-p/503916#M134764</guid>
      <dc:creator>jk101564</dc:creator>
      <dc:date>2018-10-12T21:21:04Z</dc:date>
    </item>
  </channel>
</rss>

