<?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: rewriting a program using Format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788538#M252139</link>
    <description>&lt;P&gt;Sorry i dont understand your suggestion&lt;/P&gt;&lt;P&gt;I add it at the proc freq and at&amp;nbsp; data&amp;nbsp; i end up with 2 errors&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jan 2022 20:39:32 GMT</pubDate>
    <dc:creator>Armand_B</dc:creator>
    <dc:date>2022-01-05T20:39:32Z</dc:date>
    <item>
      <title>rewriting a program using Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788525#M252131</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;i m trying to rewrite a solution( which i found not aesthetic)&amp;nbsp; here is the solution&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname cert xlsx "/home/u49144401/Cert/heart.xlsx";&lt;/P&gt;&lt;P&gt;data work.heart;&lt;BR /&gt;set cert.heart(drop=AgeAtDeath DeathCause);&lt;BR /&gt;where Status='Alive';&lt;BR /&gt;if AgeCHDiag=. then delete;&lt;BR /&gt;length Smoking_Status $17;&lt;/P&gt;&lt;P&gt;if 0&amp;lt;=Smoking&amp;lt;6 then Smoking_Status='Non-smoker(0-5)';&lt;/P&gt;&lt;P&gt;if 6&amp;lt;=Smoking&amp;lt;=15 then Smoking_Status='Moderate(6-15)';&lt;/P&gt;&lt;P&gt;if 16&amp;lt;=Smoking&amp;lt;25 then Smoking_Status='Heavy(16-25)';&lt;/P&gt;&lt;P&gt;if Smoking&amp;gt;25 then Smoking_Status='Very Heavy(16-25)';&lt;/P&gt;&lt;P&gt;else Smoking_Status='Error';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc freq data=work.heart;&lt;BR /&gt;tables AgeCHDiag*Smoking_status/norow nocol nopercent;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Following is the code i m trying to write...But i have spent more than 2 hours to try to understand what is wrong...please help&lt;BR /&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc format;&lt;BR /&gt;value smoking&lt;BR /&gt;0 -&amp;lt;6 ="None(0-5)"&lt;/P&gt;&lt;P&gt;6- 15 ="Moderate(6-15)"&lt;BR /&gt;16-25 ="Heavy(16-25)"&lt;BR /&gt;26 - high= "Very Heavy(&amp;gt;25)"&lt;BR /&gt;other ="Error";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;libname cert xlsx "/home/u49144401/Cert/heart.xlsx";&lt;BR /&gt;data work.hearts;&lt;BR /&gt;set cert.heart(drop=AgeAtDeath DeathCause);&lt;BR /&gt;where Status='Alive';&lt;BR /&gt;if AgeCHDiag=. then delete;&lt;BR /&gt;length Smoking_Status $17;&lt;BR /&gt;format Smoking_Status smoking.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc freq data=work.hearts;&lt;BR /&gt;tables AgeCHDiag*Smoking_Status/norow nocol nopercent;&lt;BR /&gt;format Smoking_Status smoking.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LOGFILE ERROR: You are trying to use the numéric format SMOKING with the character variable Smoking_Status in data set WORK.HEARTS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 19:28:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788525#M252131</guid>
      <dc:creator>Armand_B</dc:creator>
      <dc:date>2022-01-05T19:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: rewriting a program using Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788527#M252133</link>
      <description>&lt;P&gt;Smoking_status is a character variable. You would have to use a character format on it, but the format is a numeric format. You can't apply numeric formats to character variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you really want to do is to apply format SMOKING to variable SMOKING (and get rid of variable SMOKING_STATUS).&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 19:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788527#M252133</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-05T19:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: rewriting a program using Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788535#M252137</link>
      <description>&lt;P&gt;You dont need to but if you must create the char variable, replace the format statememt with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Smoking_Status=(put (smoking,smoking.));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Jan 2022 20:32:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788535#M252137</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2022-01-05T20:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: rewriting a program using Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788538#M252139</link>
      <description>&lt;P&gt;Sorry i dont understand your suggestion&lt;/P&gt;&lt;P&gt;I add it at the proc freq and at&amp;nbsp; data&amp;nbsp; i end up with 2 errors&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 20:39:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788538#M252139</guid>
      <dc:creator>Armand_B</dc:creator>
      <dc:date>2022-01-05T20:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: rewriting a program using Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788539#M252140</link>
      <description>&lt;P&gt;will you explain with code i would appreciate&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 20:40:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788539#M252140</guid>
      <dc:creator>Armand_B</dc:creator>
      <dc:date>2022-01-05T20:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: rewriting a program using Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788541#M252141</link>
      <description>please show your code and log&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Jan 2022 20:54:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788541#M252141</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2022-01-05T20:54:05Z</dc:date>
    </item>
    <item>
      <title>thats the code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788542#M252142</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;68&lt;/DIV&gt;&lt;DIV class=""&gt;69 proc format;&lt;/DIV&gt;&lt;DIV class=""&gt;70 value smoking&lt;/DIV&gt;&lt;DIV class=""&gt;71 0 -&amp;lt;6 ="None(0-5)"&lt;/DIV&gt;&lt;DIV class=""&gt;72 6- 15 ="Moderate(6-15)"&lt;/DIV&gt;&lt;DIV class=""&gt;73 16-25 ="Heavy(16-25)"&lt;/DIV&gt;&lt;DIV class=""&gt;74 26 - high= "Very Heavy(&amp;gt;25)"&lt;/DIV&gt;&lt;DIV class=""&gt;75 other ="Error";&lt;/DIV&gt;&lt;DIV class=""&gt;NOTE: Format SMOKING has been output.&lt;/DIV&gt;&lt;DIV class=""&gt;76 run;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;NOTE: PROCEDURE FORMAT a utilisé (Durée totale du traitement) :&lt;/DIV&gt;&lt;DIV class=""&gt;real time 0.00 seconds&lt;/DIV&gt;&lt;DIV class=""&gt;user cpu time 0.01 seconds&lt;/DIV&gt;&lt;DIV class=""&gt;system cpu time 0.01 seconds&lt;/DIV&gt;&lt;DIV class=""&gt;memory 302.68k&lt;/DIV&gt;&lt;DIV class=""&gt;OS Memory 23968.00k&lt;/DIV&gt;&lt;DIV class=""&gt;Timestamp 05/01/2022 08:58:12 PM&lt;/DIV&gt;&lt;DIV class=""&gt;Step Count 61 Switch Count 0&lt;/DIV&gt;&lt;DIV class=""&gt;Page Faults 0&lt;/DIV&gt;&lt;DIV class=""&gt;Page Reclaims 41&lt;/DIV&gt;&lt;DIV class=""&gt;Page Swaps 0&lt;/DIV&gt;&lt;DIV class=""&gt;Voluntary Context Switches 0&lt;/DIV&gt;&lt;DIV class=""&gt;Involuntary Context Switches 0&lt;/DIV&gt;&lt;DIV class=""&gt;Block Input Operations 0&lt;/DIV&gt;&lt;DIV class=""&gt;Block Output Operations 40&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;77&lt;/DIV&gt;&lt;DIV class=""&gt;78 libname cert xlsx "/home/u49144401/Cert/heart.xlsx";&lt;/DIV&gt;&lt;DIV class=""&gt;NOTE: Libref CERT was successfully assigned as follows:&lt;/DIV&gt;&lt;DIV class=""&gt;Engine: XLSX&lt;/DIV&gt;&lt;DIV class=""&gt;Physical Name: /home/u49144401/Cert/heart.xlsx&lt;/DIV&gt;&lt;DIV class=""&gt;79 data work.hearts;&lt;/DIV&gt;&lt;DIV class=""&gt;80 set cert.heart(drop=AgeAtDeath DeathCause);&lt;/DIV&gt;&lt;DIV class=""&gt;81 where Status='Alive';&lt;/DIV&gt;&lt;DIV class=""&gt;82 if AgeCHDiag=. then delete;&lt;/DIV&gt;&lt;DIV class=""&gt;83 length Smoking_Status $17;&lt;/DIV&gt;&lt;DIV class=""&gt;WARNING: Length of character variable Smoking_Status has already been set.&lt;/DIV&gt;&lt;DIV class=""&gt;Use the LENGTH statement as the very first statement in the DATA STEP to declare the length of a character variable.&lt;/DIV&gt;&lt;DIV class=""&gt;84 Smoking_Status=(put (smoking,smoking.));&lt;/DIV&gt;&lt;DIV class=""&gt;85 run;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;NOTE: Variable AgeCHDiag is uninitialized.&lt;/DIV&gt;&lt;DIV class=""&gt;NOTE: The import data set has 5209 observations and 17 variables.&lt;/DIV&gt;&lt;DIV class=""&gt;NOTE: There were 3218 observations read from the data set CERT.heart.&lt;/DIV&gt;&lt;DIV class=""&gt;WHERE Status='Alive';&lt;/DIV&gt;&lt;DIV class=""&gt;NOTE: The data set WORK.HEARTS has 0 observations and 16 variables.&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class=""&gt;NOTE: DATA statement a utilisé (Durée totale du traitement) :&lt;/DIV&gt;&lt;DIV class=""&gt;real time 0.74 seconds&lt;/DIV&gt;&lt;DIV class=""&gt;user cpu time 0.74 seconds&lt;/DIV&gt;&lt;DIV class=""&gt;system cpu time 0.00 seconds&lt;/DIV&gt;&lt;DIV class=""&gt;memory 2971.40k&lt;/DIV&gt;&lt;DIV class=""&gt;OS Memory 26532.00k&lt;/DIV&gt;&lt;DIV class=""&gt;Timestamp 05/01/2022 08:58:13 PM&lt;/DIV&gt;&lt;DIV class=""&gt;Step Count 62 Switch Count 2&lt;/DIV&gt;&lt;DIV class=""&gt;Page Faults 0&lt;/DIV&gt;&lt;DIV class=""&gt;Page Reclaims 685&lt;/DIV&gt;&lt;DIV class=""&gt;Page Swaps 0&lt;/DIV&gt;&lt;DIV class=""&gt;Voluntary Context Switches 18&lt;/DIV&gt;&lt;DIV class=""&gt;Involuntary Context Switches 1&lt;/DIV&gt;&lt;DIV class=""&gt;Block Input Operations 0&lt;/DIV&gt;&lt;DIV class=""&gt;Block Output Operations 264&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;86&lt;/DIV&gt;&lt;DIV class=""&gt;87 proc freq data=work.hearts;&lt;/DIV&gt;&lt;DIV class=""&gt;88 tables AgeCHDiag*Smoking_Status/norow nocol nopercent;&lt;/DIV&gt;&lt;DIV class=""&gt;89 Smoking_Status=(put (smoking,smoking.));&lt;/DIV&gt;&lt;DIV class=""&gt;______________&lt;/DIV&gt;&lt;DIV class=""&gt;180&lt;/DIV&gt;&lt;DIV class=""&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/DIV&gt;&lt;DIV class=""&gt;90 run;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/DIV&gt;&lt;DIV class=""&gt;NOTE: PROCEDURE FREQ a utilisé (Durée totale du traitement) :&lt;/DIV&gt;&lt;DIV class=""&gt;real time 0.00 seconds&lt;/DIV&gt;&lt;DIV class=""&gt;user cpu time 0.00 seconds&lt;/DIV&gt;&lt;DIV class=""&gt;system cpu time 0.00 seconds&lt;/DIV&gt;&lt;DIV class=""&gt;memory 445.53k&lt;/DIV&gt;&lt;DIV class=""&gt;OS Memory 24740.00k&lt;/DIV&gt;&lt;DIV class=""&gt;Timestamp 05/01/2022 08:58:13 PM&lt;/DIV&gt;&lt;DIV class=""&gt;Step Count 63 Switch Count 0&lt;/DIV&gt;&lt;DIV class=""&gt;Page Faults 0&lt;/DIV&gt;&lt;DIV class=""&gt;Page Reclaims 50&lt;/DIV&gt;&lt;DIV class=""&gt;Page Swaps 0&lt;/DIV&gt;&lt;DIV class=""&gt;Voluntary Context Switches 0&lt;/DIV&gt;&lt;DIV class=""&gt;Involuntary Context Switches 0&lt;/DIV&gt;&lt;DIV class=""&gt;Block Input Operations 0&lt;/DIV&gt;&lt;DIV class=""&gt;Block Output Operations 0&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&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;/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 class=""&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Wed, 05 Jan 2022 21:00:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788542#M252142</guid>
      <dc:creator>Armand_B</dc:creator>
      <dc:date>2022-01-05T21:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: thats the code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788545#M252145</link>
      <description>Smoking_Status=(put (smoking,smoking.));&lt;BR /&gt;Only in the data step and not in the proc. I'm assuming you are creating&lt;BR /&gt;this var to include in your excel file, otheri you don't it&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Jan 2022 21:08:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788545#M252145</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2022-01-05T21:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: rewriting a program using Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788548#M252147</link>
      <description>&lt;P&gt;Commenting and formatting your code would really really help you here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use SAS autoformat options at the least to help make your code legible.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*creates a format for a numeric variable;

proc format;
	value smoking 0 -&amp;lt;6="None(0-5)" 6- 15="Moderate(6-15)" 16-25="Heavy(16-25)" 
		26 - high="Very Heavy(&amp;gt;25)" other="Error";
run;

*creates a library to read in data;
libname cert xlsx "/home/u49144401/Cert/heart.xlsx";
*creates a data set called hearts;

data hearts;
	*reads in heart data set;
	set cert.heart(drop=AgeAtDeath DeathCause);
	*keeps only records where people are alive;
	where Status='Alive';
	*deletes records where missing Age of diagnosis - could be included in the WHERE clause for more efficient code;

	if AgeCHDiag=. then
		delete;
	*Your variable is smoking - not smoking status;
	*applies format smoking to your smoking variable;
	format Smoking smoking.;
	*creates smoking_status variable as a character variable;
	*this converts the variable. The format is also applied so this step is optional;
	Smoking_Status=put(smoking, smoking.);
run;

title 'Smoking Variable';

proc freq data=hearts;
	tables AgeCHDiag*Smoking / norow nocol nopercent;
run;

title 'Smoking Status Variable';

proc freq data=hearts;
	tables AgeCHDiag*Smoking_STATUS / norow nocol nopercent;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 21:23:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788548#M252147</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-05T21:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: thats the code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788549#M252148</link>
      <description>&lt;P&gt;I am ending up with 2 errors&lt;/P&gt;&lt;DIV class=""&gt;data work.hearts;&lt;/DIV&gt;&lt;DIV class=""&gt;79 set work.heart(drop=AgeAtDeath DeathCause);&lt;/DIV&gt;&lt;DIV class=""&gt;ERROR: The variable AgeAtDeath in the DROP, KEEP, or RENAME list has never been referenced.&lt;/DIV&gt;&lt;DIV class=""&gt;ERROR: The variable DeathCause in the DROP, KEEP, or RENAME list has never been referenced.&lt;/DIV&gt;&lt;DIV class=""&gt;80 where Status='Alive';&lt;/DIV&gt;&lt;DIV class=""&gt;81 if AgeCHDiag=. then delete;&lt;/DIV&gt;&lt;DIV class=""&gt;82&lt;/DIV&gt;&lt;DIV class=""&gt;83 length Smoking_Status $17;&lt;/DIV&gt;&lt;DIV class=""&gt;84 smoking_Status=(put(smoking,smoking.));&lt;/DIV&gt;&lt;DIV class=""&gt;85 run;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/DIV&gt;&lt;DIV class=""&gt;WARNING: The data set WORK.HEARTS may be incomplete. When this step was stopped there were 0 observations and 3 variables.&lt;/DIV&gt;&lt;DIV class=""&gt;WARNING: Data set WORK.HEARTS was not replaced because the step was stopped&lt;/DIV&gt;</description>
      <pubDate>Wed, 05 Jan 2022 21:25:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788549#M252148</guid>
      <dc:creator>Armand_B</dc:creator>
      <dc:date>2022-01-05T21:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: rewriting a program using Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788552#M252151</link>
      <description>&lt;P&gt;Thanks for your time it is well written and with comments&amp;nbsp; but.......we end up with the same issue&lt;/P&gt;&lt;P&gt;Log file message&lt;/P&gt;&lt;DIV class=""&gt;NOTE: Variable AgeCHDiag is uninitialized.&lt;/DIV&gt;&lt;DIV class=""&gt;NOTE: The import data set has 5209 observations and 17 variables.&lt;/DIV&gt;&lt;DIV class=""&gt;NOTE: There were 3218 observations read from the data set CERT.heart.&lt;/DIV&gt;&lt;DIV class=""&gt;WHERE Status='Alive';&lt;/DIV&gt;&lt;DIV class=""&gt;NOTE: The data set WORK.HEARTS has 0 observations and 16 variables.&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;NOTE: No observations in data set WORK.HEARTS.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;PS&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;how comes&amp;nbsp; ? what went wrong ?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 21:32:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788552#M252151</guid>
      <dc:creator>Armand_B</dc:creator>
      <dc:date>2022-01-05T21:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: thats the code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788553#M252152</link>
      <description>That log is not from the code I posted. Post the log from the code I posted.</description>
      <pubDate>Wed, 05 Jan 2022 21:39:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788553#M252152</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-05T21:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: rewriting a program using Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788556#M252153</link>
      <description>&lt;P&gt;The variable is ageCH&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;DD&lt;/STRONG&gt;&lt;/FONT&gt;iag - you were missing a D in your code and &lt;U&gt;&lt;STRONG&gt;without checking the actual data set we couldn't know that&lt;/STRONG&gt;&lt;/U&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
	value smoking 0 -&amp;lt;6="None(0-5)" 6- 15="Moderate(6-15)" 16-25="Heavy(16-25)" 
		26 - high="Very Heavy(&amp;gt;25)" other="Error";
run;

*creates a library to read in data;
libname cert xlsx "/home/u49144401/Cert/heart.xlsx";
*creates a data set called hearts;

data hearts;
	*reads in heart data set;
	set sashelp.heart(drop=AgeAtDeath DeathCause);
	*keeps only records where people are alive;
	where Status='Alive';
	*deletes records where missing Age of diagnosis - could be included in the WHERE clause for more efficient code;

	if AgeCHDdiag=. then
		delete;
	*Your variable is smoking - not smoking status;
	*applies format smoking to your smoking variable;
	format Smoking smoking.;
	*creates smoking_status variable as a character variable;
	*this converts the variable. The format is also applied so this step is optional;
	Smoking_Status=put(smoking, smoking.);
run;

title 'Smoking Variable - with MISSING';

proc freq data=hearts;
	tables AgeCHDDiag*Smoking / norow nocol nopercent missing;
run;

title 'Smoking Status Variable - with ERROR';

proc freq data=hearts;
	tables AgeCHDDiag*Smoking_STATUS / norow nocol nopercent;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Jan 2022 21:44:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788556#M252153</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-05T21:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: rewriting a program using Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788558#M252155</link>
      <description>It's worth noting both your errors were due to incorrectly referencing variable names - in one case referring to the wrong variable and in the other misspelling a variable name.</description>
      <pubDate>Wed, 05 Jan 2022 21:46:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788558#M252155</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-05T21:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: rewriting a program using Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788562#M252158</link>
      <description>&lt;P&gt;Thanks for your comittment...Now the solution work very well&lt;/P&gt;&lt;P&gt;a) i had the SAS Prep Guide it has typing errors.....so i forgot to list the dataset in order to see whether names were properly written&lt;/P&gt;&lt;P&gt;b) i spent 3 hours thinking about rewriting the solution....with your help i was successful&lt;/P&gt;&lt;P&gt;Thanks for saving me this worry&lt;/P&gt;&lt;P&gt;my regards&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 21:59:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rewriting-a-program-using-Format/m-p/788562#M252158</guid>
      <dc:creator>Armand_B</dc:creator>
      <dc:date>2022-01-05T21:59:45Z</dc:date>
    </item>
  </channel>
</rss>

