<?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 output statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/output-statement/m-p/852725#M337057</link>
    <description>&lt;PRE&gt;data range;
length score_lbl $15. sort_order 8.;
score_lbl="score&amp;lt;540"; sort_order=1; output;
score_lbl="540&amp;lt;=score&amp;lt;550"; sort_order=2; output;
score_lbl="550&amp;lt;score&amp;lt;560"; sort+order=3;output;
run;



&lt;/PRE&gt;
&lt;P&gt;how does this work? assign value to score_lbl and sort_order in turn and output together?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 09 Jan 2023 04:49:14 GMT</pubDate>
    <dc:creator>HeatherNewton</dc:creator>
    <dc:date>2023-01-09T04:49:14Z</dc:date>
    <item>
      <title>output statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-statement/m-p/852725#M337057</link>
      <description>&lt;PRE&gt;data range;
length score_lbl $15. sort_order 8.;
score_lbl="score&amp;lt;540"; sort_order=1; output;
score_lbl="540&amp;lt;=score&amp;lt;550"; sort_order=2; output;
score_lbl="550&amp;lt;score&amp;lt;560"; sort+order=3;output;
run;



&lt;/PRE&gt;
&lt;P&gt;how does this work? assign value to score_lbl and sort_order in turn and output together?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 04:49:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-statement/m-p/852725#M337057</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2023-01-09T04:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: output statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-statement/m-p/852731#M337058</link>
      <description>&lt;P&gt;Maxim 1: Read the Documentation.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1lltvbis7ye1an1eryo4leh2mck.htm" target="_blank" rel="noopener"&gt;OUTPUT Statement&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your head will not explode, and you won't lose your eyesight or suffer similar mishaps. Once you've done that, and there are parts of the doc which are unclear to you, come back here, and we'll clear them up.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 07:08:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-statement/m-p/852731#M337058</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-01-09T07:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: output statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-statement/m-p/852732#M337059</link>
      <description>&lt;P&gt;And, of course, Maxim 4. Just run the code and look at the resulting dataset.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 07:10:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-statement/m-p/852732#M337059</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-01-09T07:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: output statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-statement/m-p/852771#M337064</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/416388"&gt;@HeatherNewton&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;data range;
length score_lbl $15. sort_order 8.;
score_lbl="score&amp;lt;540"; sort_order=1; output;
score_lbl="540&amp;lt;=score&amp;lt;550"; sort_order=2; output;
score_lbl="550&amp;lt;score&amp;lt;560"; sort+order=3;output;
run;



&lt;/PRE&gt;
&lt;P&gt;how does this work? assign value to score_lbl and sort_order in turn and output together?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It doesn't work, because you have no SET statement or INPUT statement. All values are missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, if we take a step back, the text string of SCORE_LBL has to be sorted to get them into order, because SAS by default sort text alphabetically, not numerically. It would be far better if SCORE were kept as a numeric value and not converted into a text variable, and then the values of score will sort numerically. How to use SCORE as a numeric variable? Assign custom formats, rather the creating a new text variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value scoref low-&amp;lt;540='Score &amp;lt; 540' 
        540-&amp;lt;550='540&amp;lt;=Score&amp;lt;550'
        550-&amp;lt;560='550&amp;lt;=Score&amp;lt;560';
run;

/* Example of use */
proc freq data=have order=internal;
    table score;
    format score scoref.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So don't assign ranges as text strings; assign ranges as a custom format.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 11:55:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-statement/m-p/852771#M337064</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-09T11:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: output statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-statement/m-p/852797#M337070</link>
      <description>&lt;PRE&gt;proc format;
value SCOREFMT
low-539="SCORE&amp;lt;540"
540-559="540&amp;lt;=SCORE&amp;lt;560"
;
RUN;

DATA RANGE;
LENGTH SCORE_LBL $25. SORT_ORDER 8.;
SCORE_LBL="SCORE&amp;lt;540"; SORT_ORDER=1; OUTPUT;
SCORE_LBL="540&amp;lt;=SCORE&amp;lt;560"; SORT_ORDER=2; OUTPUT;
RUN;

PROC PRINT DATA=RANGE;
RUN;&lt;/PRE&gt;
&lt;P&gt;actually this is the code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when print, I get score_lbl instead of score as variable name,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;it shows score_lbl and sort_order not score&lt;/P&gt;
&lt;P&gt;how does this work?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 13:58:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-statement/m-p/852797#M337070</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2023-01-09T13:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: output statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-statement/m-p/852803#M337072</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value scoref low-&amp;lt;540='Score &amp;lt; 540' 
        540-&amp;lt;550='540&amp;lt;=Score&amp;lt;550'
        550-&amp;lt;560='550&amp;lt;=Score&amp;lt;560';
run;

/* Example of use */
proc print data=range(drop=score_lbl);
    format score scoref.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Jan 2023 14:10:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-statement/m-p/852803#M337072</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-09T14:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: output statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-statement/m-p/852817#M337081</link>
      <description>&lt;P&gt;It is just creating a dataset with three observations and two variables.&lt;/P&gt;
&lt;P&gt;So it is just an overly complicated way of writing this data step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data range;
  sort_order +1 ;
  input score_lbl $15. ;
cards;
score&amp;lt;540
540&amp;lt;=score&amp;lt;550
550&amp;lt;score&amp;lt;560
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Jan 2023 15:17:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-statement/m-p/852817#M337081</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-01-09T15:17:58Z</dc:date>
    </item>
  </channel>
</rss>

