<?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: Proc Report issues: how to prevent data from automatic ordering in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-issues-how-to-prevent-data-from-automatic-ordering/m-p/862326#M340614</link>
    <description>&lt;P&gt;&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;Thank you for your feedback.&amp;nbsp; Below if my code from Proc report and Data (simulated) that i'm working on. I was using&amp;nbsp; &lt;STRONG&gt;define VISIT/ group&lt;/STRONG&gt; statement. But &lt;STRONG&gt;order=data&lt;/STRONG&gt; option is what I'm looking for. It really does the job the way I expected. Thank you!&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;,&amp;nbsp;I like the approach you suggested, but the above way seems more efficient in my situation. I appreciate your time and support!&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440357"&gt;@Shaik_Adil&lt;/a&gt;,&amp;nbsp;I'm providing the data and codes below as an answer to your question. Thank you for checking in with me!&lt;BR /&gt;&lt;BR /&gt;Again, thank you all for spending time to read and answer my post!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
	length Visit $25; 
	input VISIT $ _n _mean _std ;
	datalines;
	Week12 210 0.55 0.84
	Month8 150 0.05 0.73
	Month12 120 0.07 0.51
	Month16 135 0.33 0.65
	Month20 101 0.06 0.43
	Month24 256 0.35 0.71
	Month28 175 0.11 0.43
	;
run; 

ods tagsets.excelxp file = "C:\Users\Desktop\test\Score_tables.xml" style=listing
	options(sheet_name= "Table 3 - Categorical" embedded_titles = "on" embedded_footnotes = "on" Merge_Titles_Footnotes = "on" missing_align= 'center' Row_Heights='24,16,0,32,32,0,0' Skip_Space= '0,0,0,1,1');
	proc report data= have spanrows style(report)={background=white borderrightcolor=white borderleftcolor=white bordertopcolor=black borderbottomcolor=black bordertopwidth=1pt borderbottomwidth=1pt}
								 			style(header)={height=24pt font_face='TREBUCHET MS' fontsize=11pt background=white borderrightcolor=white borderleftcolor=white bordertopcolor=black borderbottomcolor=black bordertopwidth=1 borderbottomwidth=1} out=report_scorechange;
		column visit _n _mean _std;
		define visit/ "VISIT" width=25 style(header)= {just=l} style(column)= {just=l font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} group;
		define _n/ "n" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		define _mean/ "Mean" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		define _std/ "SD" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		compute before visit/ style = {indent=2 just=l font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt};
			Line @3 Text $50.;
			length text $50;
			if strip(visit) eq "Week12" then text= "Reference Timepoint";
			else text= "Change from Week 12";
		endcomp;
	run; 
ods tagsets.excelxp close;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 05 Mar 2023 00:47:43 GMT</pubDate>
    <dc:creator>A_Kh</dc:creator>
    <dc:date>2023-03-05T00:47:43Z</dc:date>
    <item>
      <title>Proc Report issues: how to prevent data from automatic ordering</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-issues-how-to-prevent-data-from-automatic-ordering/m-p/862250#M340570</link>
      <description>&lt;P&gt;Dear Community,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While reporting a data in proc report my VISIT variable's order keeps changing all the time. As original data is not alphanumerically "in order", proc report automatically changes it as below:&lt;/P&gt;
&lt;TABLE width="250"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="249px" height="30px"&gt;Month 12&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="249px" height="30px"&gt;Month 16&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="249px" height="30px"&gt;Month 20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="249px" height="30px"&gt;Month 24&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="249px" height="30px"&gt;Month 28&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="249px" height="30px"&gt;Month 30&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="249px" height="30px"&gt;Month 32&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="249px" height="30px"&gt;Month 36&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="249px" height="30px"&gt;Month 48&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="249px" height="30px"&gt;&lt;STRONG&gt;Month 8&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="249px" height="30px"&gt;&lt;STRONG&gt;Week 12&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I need &lt;STRONG&gt;Week 12&lt;/STRONG&gt; and &lt;STRONG&gt;Month 8&lt;/STRONG&gt; on top of the table. I used to create numeric variable like ORDER in order to maintain the original order, but I'm curious about whether there is more efficient way of avoiding abovementioned issue, like any option that helps to keep the original order from the dataset in proc report output.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 04 Mar 2023 03:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-issues-how-to-prevent-data-from-automatic-ordering/m-p/862250#M340570</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2023-03-04T03:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report issues: how to prevent data from automatic ordering</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-issues-how-to-prevent-data-from-automatic-ordering/m-p/862260#M340576</link>
      <description>&lt;P&gt;Use a number as data, and a format to display your strings. The sequence of the ascending number will control the layout.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Mar 2023 06:32:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-issues-how-to-prevent-data-from-automatic-ordering/m-p/862260#M340576</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-04T06:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report issues: how to prevent data from automatic ordering</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-issues-how-to-prevent-data-from-automatic-ordering/m-p/862276#M340583</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/321371"&gt;@A_Kh&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Usually by default SAS prints the data in ascending order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As per your information I understood the values you mentioned are belong to "VISIT" variable.&lt;/P&gt;&lt;P&gt;And you might have using similar code to execute.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc report data=datasetname;&lt;BR /&gt;columns VISIT;&lt;BR /&gt;/* Define Visit /display; */&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For assisting you, can you please share the code and inputs for below questions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* Values seems like not getting generated from SAS, and those are strings if yes then are you typing those manually?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* These values are constant or having any dependency?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kindly correct me if am wrong.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Mar 2023 12:44:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-issues-how-to-prevent-data-from-automatic-ordering/m-p/862276#M340583</guid>
      <dc:creator>Shaik_Adil</dc:creator>
      <dc:date>2023-03-04T12:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report issues: how to prevent data from automatic ordering</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-issues-how-to-prevent-data-from-automatic-ordering/m-p/862288#M340589</link>
      <description>&lt;P&gt;One, ALWAYS show your code. The options&amp;nbsp; you pick may be the cause of your issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;IF&lt;/STRONG&gt; your data is in the order that you want it to display before the call to Proc Report then you &lt;STRONG&gt;may&lt;/STRONG&gt; be able to address the problem with the ORDER= option on the DEFINE statement for that variable&lt;/P&gt;
&lt;PRE&gt;define Visit / order=data;&lt;/PRE&gt;
&lt;P&gt;From the documentation:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV class="xis-refProc"&gt;
&lt;DIV class="xis-procStatement"&gt;
&lt;DIV class="xis-procStatementSyntax"&gt;
&lt;DIV class="xis-syntaxDescription"&gt;
&lt;DIV class="xis-optionalArgGroup"&gt;
&lt;DIV id="p0vk3hzz34jjugn16qvlcc1bfuv4" class="xis-argDescriptionPair"&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;DIV id="p1gfeafhxusq7an1mpbvw2gq8uu6" class="xis-argDescriptionPair"&gt;
&lt;H4 class="xis-argument"&gt;DATA&lt;/H4&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;orders values according to their order in the input data set&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;However, if your visit variable is not the first column then the options used defining that variable can make the Visit variable appear differently. (See why I say show your code).&lt;/P&gt;
&lt;P&gt;Also if your data source is from an external database the order may well not be preserved depending on source and how the connection is implemented.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Mar 2023 14:26:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-issues-how-to-prevent-data-from-automatic-ordering/m-p/862288#M340589</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-04T14:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report issues: how to prevent data from automatic ordering</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Report-issues-how-to-prevent-data-from-automatic-ordering/m-p/862326#M340614</link>
      <description>&lt;P&gt;&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;Thank you for your feedback.&amp;nbsp; Below if my code from Proc report and Data (simulated) that i'm working on. I was using&amp;nbsp; &lt;STRONG&gt;define VISIT/ group&lt;/STRONG&gt; statement. But &lt;STRONG&gt;order=data&lt;/STRONG&gt; option is what I'm looking for. It really does the job the way I expected. Thank you!&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;,&amp;nbsp;I like the approach you suggested, but the above way seems more efficient in my situation. I appreciate your time and support!&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440357"&gt;@Shaik_Adil&lt;/a&gt;,&amp;nbsp;I'm providing the data and codes below as an answer to your question. Thank you for checking in with me!&lt;BR /&gt;&lt;BR /&gt;Again, thank you all for spending time to read and answer my post!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
	length Visit $25; 
	input VISIT $ _n _mean _std ;
	datalines;
	Week12 210 0.55 0.84
	Month8 150 0.05 0.73
	Month12 120 0.07 0.51
	Month16 135 0.33 0.65
	Month20 101 0.06 0.43
	Month24 256 0.35 0.71
	Month28 175 0.11 0.43
	;
run; 

ods tagsets.excelxp file = "C:\Users\Desktop\test\Score_tables.xml" style=listing
	options(sheet_name= "Table 3 - Categorical" embedded_titles = "on" embedded_footnotes = "on" Merge_Titles_Footnotes = "on" missing_align= 'center' Row_Heights='24,16,0,32,32,0,0' Skip_Space= '0,0,0,1,1');
	proc report data= have spanrows style(report)={background=white borderrightcolor=white borderleftcolor=white bordertopcolor=black borderbottomcolor=black bordertopwidth=1pt borderbottomwidth=1pt}
								 			style(header)={height=24pt font_face='TREBUCHET MS' fontsize=11pt background=white borderrightcolor=white borderleftcolor=white bordertopcolor=black borderbottomcolor=black bordertopwidth=1 borderbottomwidth=1} out=report_scorechange;
		column visit _n _mean _std;
		define visit/ "VISIT" width=25 style(header)= {just=l} style(column)= {just=l font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} group;
		define _n/ "n" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		define _mean/ "Mean" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		define _std/ "SD" center width=8 style(column)= {just=c font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt} display;
		compute before visit/ style = {indent=2 just=l font_face='TREBUCHET MS' fontsize=11pt borderleftcolor=white borderleftwidth=.5pt borderrightcolor=white borderrightwidth=.5pt};
			Line @3 Text $50.;
			length text $50;
			if strip(visit) eq "Week12" then text= "Reference Timepoint";
			else text= "Change from Week 12";
		endcomp;
	run; 
ods tagsets.excelxp close;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Mar 2023 00:47:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Report-issues-how-to-prevent-data-from-automatic-ordering/m-p/862326#M340614</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2023-03-05T00:47:43Z</dc:date>
    </item>
  </channel>
</rss>

