<?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: How to Format Many Sequential Numeric Values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264247#M310242</link>
    <description>&lt;P&gt;I think you can get there by creating two formats. &amp;nbsp;I can't check the syntax right now, so you may need to debug:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format;&lt;/P&gt;
&lt;P&gt;value all 0='Screening' 98='Follow-up' 99='Unscheduled' other=[cycles.];&lt;/P&gt;
&lt;P&gt;picture cycles low-high = 'Cycle 99';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Apr 2016 18:42:53 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-04-15T18:42:53Z</dc:date>
    <item>
      <title>How to Format Many Sequential Numeric Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264237#M310240</link>
      <description>&lt;P&gt;I have a character timepoint value that I have coded as numeric for sorting purposes. &amp;nbsp;My possible values are:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;Character&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;Numeric&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Screening&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;0&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Cycle 1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Cycle 2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Cycle 3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;…&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;…&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Cycle 22&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;22&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Follow-Up&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;98&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Unscheduled&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;99&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In these cases, I usually assign a numeric value to the character value in the order that I want and then apply a format to the numeric values since sorting the character values would result in Cycle 1, Cycle 10, Cycle 11... instead of Cycle 1, Cycle 2, Cycle3.... &amp;nbsp;This seems tedious in my current situation, so I was wondering if there is a more efficient way. &amp;nbsp;I wanted to try a picture format where I just use a "Cycle" prefix to all the number 1-22 and somehow format 0, 98, and 99 as desired. &amp;nbsp;Any ideas on how to proceed?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If not, I may just type everything out in a regular format or use a loop in the future if this&amp;nbsp;arises more often.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2016 18:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264237#M310240</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2016-04-15T18:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to Format Many Sequential Numeric Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264244#M310241</link>
      <description>&lt;P&gt;Hi mate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I didn't get exactly what you need.&lt;/P&gt;
&lt;P&gt;Here is what i get:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
 value score 1 - 22 = 'Cycle 1-22'
 22&amp;lt;- 98 = '0-98'
 other = '99'
 ;run;
 
 
data test;
	length var 8;
   	input var;
   	datalines;
   1
   2
   3
   4
   22
   98
   99
   ;;;;
run;

data want;
  set test;
  new_var=var;
  format new_var score.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2016 18:39:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264244#M310241</guid>
      <dc:creator>DartRodrigo</dc:creator>
      <dc:date>2016-04-15T18:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to Format Many Sequential Numeric Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264247#M310242</link>
      <description>&lt;P&gt;I think you can get there by creating two formats. &amp;nbsp;I can't check the syntax right now, so you may need to debug:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format;&lt;/P&gt;
&lt;P&gt;value all 0='Screening' 98='Follow-up' 99='Unscheduled' other=[cycles.];&lt;/P&gt;
&lt;P&gt;picture cycles low-high = 'Cycle 99';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2016 18:42:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264247#M310242</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-04-15T18:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to Format Many Sequential Numeric Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264249#M310243</link>
      <description>&lt;P&gt;Actually, this is what I'm trying to do in long hand:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
	value timept
		0='Screening'
		1='Cycle 1'
		2='Cycle 2'
		3='Cycle 3'
		4='Cycle 4'
		5='Cycle 5'
		6='Cycle 6'
		7='Cycle 7'
		8='Cycle 8'
		9='Cycle 9'
		10='Cycle 10'
		11='Cycle 11'
		12='Cycle 12'
		13='Cycle 13'
		14='Cycle 14'
		15='Cycle 15'
		16='Cycle 16'
		17='Cycle 17'
		18='Cycle 18'
		19='Cycle 19'
		20='Cycle 20'
		21='Cycle 21'
		22='Cycle 22'
		98='Follow-up'
		99='Unscheduled';
run;


data test;
	var=0; output;
	do var=1 to 22;
		output;
	end;
	var=98; output;
	var=99; output;
run;

data want;
  set test;
  new_var=var;
  format new_var timept.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If there is a better way than writing out every format option since there is a lot of repeat with "Cycle", I would like to incorporate that.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2016 18:47:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264249#M310243</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2016-04-15T18:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to Format Many Sequential Numeric Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264251#M310244</link>
      <description>&lt;P&gt;It didn't work quite as you presented it, but I made a few changes (see below). &amp;nbsp;My only concern now is how I would get rid of all the leading spaces in the values 1-22:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
	value all
		0='Screening' 98='Follow-up' 99='Unscheduled' other=[cycles.];
	picture cycles low-high = '99' (prefix='Cycle ');
run;

data test;
	var=0; output;
	do var=1 to 22;
		output;
	end;
	var=98; output;
	var=99; output;
run;

data want;
  set test;
  new_var=var;
  format new_var all.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Apr 2016 18:51:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264251#M310244</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2016-04-15T18:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to Format Many Sequential Numeric Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264253#M310245</link>
      <description>&lt;P&gt;This seems to do what I want, but anyone feel free to elaborate if there is a cleaner way to do this in the future.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro format;
	proc format;
		value timept
			0='Screening'
			%do i=1 %to 22;
				&amp;amp;i.="Cycle &amp;amp;i."
			%end;
			98='Follow-up'
			99='Unscheduled';
	run;
%mend format;
%format;

data test;
	var=0; output;
	do var=1 to 22;
		output;
	end;
	var=98; output;
	var=99; output;
run;

data want;
  set test;
  new_var=var;
  format new_var timept.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Apr 2016 18:59:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264253#M310245</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2016-04-15T18:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to Format Many Sequential Numeric Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264254#M310246</link>
      <description>&lt;P&gt;To get rid of leading blanks, you would need to set up two ranges in the PICTURE format:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1-9 = '9' (prefix='Cycle')&lt;/P&gt;
&lt;P&gt;10-97='99' (prefix='Cycle')&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2016 19:02:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264254#M310246</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-04-15T19:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to Format Many Sequential Numeric Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264257#M310247</link>
      <description>&lt;P&gt;If you already have the data in a data set and can summarize it then use the data to build a format for you. Something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table CycleFormat as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select distinct numeric as start, character as Label, "MyCycleFormat" as Fmtname, type='N'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from datasetname&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Where the text before Fmtname is the name of the format you want to create and type N is for numeric, C would be character.&lt;/P&gt;
&lt;P&gt;proc format &amp;lt;library=libname&amp;gt; cntlin=CycleFormat;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Library part is optional but save it to a permanent library and you can add that library to the search path for formats with:&lt;/P&gt;
&lt;P&gt;Options append=(fmtsearch=(libname));&lt;/P&gt;
&lt;P&gt;where libname is the name of your permanent library.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2016 19:10:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264257#M310247</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-04-15T19:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to Format Many Sequential Numeric Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264258#M310248</link>
      <description>&lt;P&gt;That actually addressed a second question, but not the first. &amp;nbsp;I was getting "Cycle 01" instead of "Cycle 1", which using 2 ranges&amp;nbsp;solved. &amp;nbsp;However, when I use the format, I get a 33 spaces before the text. &amp;nbsp;Maybe not an issue at this point in my project.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2016 19:10:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264258#M310248</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2016-04-15T19:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to Format Many Sequential Numeric Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264259#M310249</link>
      <description>&lt;P&gt;Not sure you can get more efficient.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I prefer proc format with a CNTLIN dataset rather than a macro myself, but it's a preference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cycle_fmt;
fmtname='cycle_fmt';
type='C';

start=0; label='Screening'; output;
start=98; label='Follow-up'; output;
start=99; label='Unscheduled'; output;

do start=1 to 22;
	label=cat("Cycle ", start);
	output;
end;
run;

proc format cntlin=cycle_fmt;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Apr 2016 19:13:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264259#M310249</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-15T19:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to Format Many Sequential Numeric Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264265#M310250</link>
      <description>&lt;P&gt;I found my issue. &amp;nbsp;The log states that there was not a length specified for the picture format, so it defaulted to a length of 40. &amp;nbsp;I just had to change the length of the cycles format:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
	picture cycles
		low-9='9' (prefix='Cycle ')
		10-high='99' (prefix='Cycle ');
	value timept
		0='Screening'
		98='Follow-up'
		99='Unscheduled'
		other=[cycles9.];
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;There is still a single space in front of Cycle 1 - Cycle 9, but oh well. &amp;nbsp;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2016 19:19:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264265#M310250</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2016-04-15T19:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to Format Many Sequential Numeric Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264268#M310251</link>
      <description>&lt;P&gt;One last reply. &amp;nbsp;In case you care for future reference, I think this is what I was looking for:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;&lt;BR /&gt; picture cycles_one&lt;BR /&gt; 1-9='9' (prefix='Cycle ');&lt;BR /&gt; picture cycles_two&lt;BR /&gt; 10-90='99' (prefix='Cycle ');&lt;BR /&gt; value timept&lt;BR /&gt; 0='Screening'&lt;BR /&gt; 1-9=[cycles_one8.]&lt;BR /&gt; 10-90=[cycles_two9.]&lt;BR /&gt; 98='Follow-up'&lt;BR /&gt; 99='Unscheduled';&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data test;&lt;BR /&gt; var=0; output;&lt;BR /&gt; do var=1 to 22;&lt;BR /&gt; output;&lt;BR /&gt; end;&lt;BR /&gt; var=98; output;&lt;BR /&gt; var=99; output;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt; set test;&lt;BR /&gt; new_var=var;&lt;BR /&gt; format new_var timept.;&lt;BR /&gt;run;&lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Apr 2016 19:28:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264268#M310251</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2016-04-15T19:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to Format Many Sequential Numeric Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264311#M310252</link>
      <description>&lt;P&gt;You can ask&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/34537"&gt;@BeverlyBrown﻿&lt;/a&gt;&amp;nbsp;to change the correct answer &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2016 22:59:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264311#M310252</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-15T22:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to Format Many Sequential Numeric Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264358#M310253</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/74"&gt;@djbateman﻿&lt;/a&gt;: Anyone can edit their own post (use down arrow by the wheel at upper right of comment.) Or did I misunderstand the question? Certainly possible.&amp;nbsp;&lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt; In any case, glad to see such healthy discussion and a good outcome!&lt;/P&gt;</description>
      <pubDate>Sat, 16 Apr 2016 15:07:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Format-Many-Sequential-Numeric-Values/m-p/264358#M310253</guid>
      <dc:creator>BeverlyBrown</dc:creator>
      <dc:date>2016-04-16T15:07:55Z</dc:date>
    </item>
  </channel>
</rss>

