<?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: Sas format questions in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Sas-format-questions/m-p/793280#M38875</link>
    <description>&lt;P&gt;Here is a short introduction to using PROC FORMAT to define a format:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2019/06/10/5-reasons-to-use-proc-format-to-recode-variables-in-sas.html" target="_self"&gt;"Use PROC FORMAT to recode variables in SAS"&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As shown in the article,&amp;nbsp;you use the FORMAT statement to tell that SAS to display a variable's formatted values instead of its raw values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To "apply" a format to more than one variable, list all the variables after the word FORMAT and then put the name of the format at the end of the line. For example, to apply the YESNO format to four variables, you would use&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;format HospDeath IntenCare MechVent Asthma YESNO.;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notice that the FORMAT statement needs to be INSIDE a DATA step or PROC/RUN boundary. It is not a global statement.&lt;/P&gt;</description>
    <pubDate>Sat, 29 Jan 2022 11:41:37 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2022-01-29T11:41:37Z</dc:date>
    <item>
      <title>Sas format questions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sas-format-questions/m-p/793268#M38873</link>
      <description>&lt;OL&gt;&lt;LI&gt;&lt;SPAN&gt;Create a format called &lt;/SPAN&gt;&lt;SPAN&gt;YESNO&lt;/SPAN&gt;&lt;SPAN&gt; where 1 = “Yes” and 2 = “No” and apply it to all variables in the dataset with that coding.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Create formats for &lt;/SPAN&gt;&lt;SPAN&gt;SEX&lt;/SPAN&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;SPAN&gt;RACEETHN&lt;/SPAN&gt;&lt;SPAN&gt; and apply them to the associated variables.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Create an &lt;/SPAN&gt;&lt;SPAN&gt;AGE&lt;/SPAN&gt;&lt;SPAN&gt; variable that is patient age at hospitalization.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Categorize the new &lt;/SPAN&gt;&lt;SPAN&gt;AGE&lt;/SPAN&gt;&lt;SPAN&gt; variable into a variable called &lt;/SPAN&gt;&lt;SPAN&gt;AGEGROUP&lt;/SPAN&gt;&lt;SPAN&gt; with the following categories:&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;SPAN&gt;1 = 0-4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2 = 5-17&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3 = 18-49&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;4 = 50-64&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;5 = ≥65&lt;/SPAN&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN&gt;Create and apply a format for the new age category variable.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Run a PROC FREQ to describe the number of hospital deaths by age group. Report which group experienced the most deaths over the period of observation.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Sat, 29 Jan 2022 07:21:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sas-format-questions/m-p/793268#M38873</guid>
      <dc:creator>saza</dc:creator>
      <dc:date>2022-01-29T07:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: Sas format questions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sas-format-questions/m-p/793278#M38874</link>
      <description>&lt;P&gt;Show us what you have tried.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Jan 2022 11:21:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sas-format-questions/m-p/793278#M38874</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-29T11:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: Sas format questions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sas-format-questions/m-p/793280#M38875</link>
      <description>&lt;P&gt;Here is a short introduction to using PROC FORMAT to define a format:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2019/06/10/5-reasons-to-use-proc-format-to-recode-variables-in-sas.html" target="_self"&gt;"Use PROC FORMAT to recode variables in SAS"&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As shown in the article,&amp;nbsp;you use the FORMAT statement to tell that SAS to display a variable's formatted values instead of its raw values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To "apply" a format to more than one variable, list all the variables after the word FORMAT and then put the name of the format at the end of the line. For example, to apply the YESNO format to four variables, you would use&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;format HospDeath IntenCare MechVent Asthma YESNO.;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notice that the FORMAT statement needs to be INSIDE a DATA step or PROC/RUN boundary. It is not a global statement.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Jan 2022 11:41:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sas-format-questions/m-p/793280#M38875</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-01-29T11:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: Sas format questions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sas-format-questions/m-p/793308#M38876</link>
      <description>I tried to set 1 and 2 to yes or no In a new dates called "covid" but am getting errors.&lt;BR /&gt;data=covid;&lt;BR /&gt;set covidk.covid1k;&lt;BR /&gt;format 1 $YES;&lt;BR /&gt;format 2 $NO;&lt;BR /&gt;run;</description>
      <pubDate>Sat, 29 Jan 2022 19:57:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sas-format-questions/m-p/793308#M38876</guid>
      <dc:creator>saza</dc:creator>
      <dc:date>2022-01-29T19:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: Sas format questions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sas-format-questions/m-p/793315#M38881</link>
      <description>&lt;P&gt;So, there are plenty of examples out there in the world of correct use of formats. &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt; has pointed you to some. Here is another example, from the SAS documentation: &lt;A href="http://documentation.sas.com/doc/en/pgmmvacdc/9.4/proc/n03qskwoints2an1ispy57plwrn9.htm" target="_blank"&gt;http://documentation.sas.com/doc/en/pgmmvacdc/9.4/proc/n03qskwoints2an1ispy57plwrn9.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See if you can follow any of those examples.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Jan 2022 21:10:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sas-format-questions/m-p/793315#M38881</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-29T21:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: Sas format questions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sas-format-questions/m-p/793317#M38882</link>
      <description>&lt;P&gt;In the article,&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2019/06/10/5-reasons-to-use-proc-format-to-recode-variables-in-sas.html" target="_blank"&gt;5 reasons to use PROC FORMAT to recode variables in SAS - The DO Loop&lt;/A&gt;, look for the PROC FORMAT step. That shows how to define a format. For example&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value YESNO
      0 = "Yes"
      1 = "No" 
      other = " ";
run;

proc freq data=covid1k;
format HospDeath IntenCare MechVent Asthma YESNO.;
tables HospDeath IntenCare MechVent Asthma;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 29 Jan 2022 21:20:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sas-format-questions/m-p/793317#M38882</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-01-29T21:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: Sas format questions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Sas-format-questions/m-p/793419#M38884</link>
      <description>Thank you for your feedback! I believe I was able to crack the code using your resources:&lt;BR /&gt;&lt;BR /&gt;libname covid1k '/home/u59291263/folder for sas lab';&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data=covid;&lt;BR /&gt;set covidk.covid1k;&lt;BR /&gt;format 1 $YES;&lt;BR /&gt;format 2 $NO;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data covid;&lt;BR /&gt;set covid1k.covid1k;&lt;BR /&gt;format SEX 1= $YES&lt;BR /&gt;2= $NO;&lt;BR /&gt;run;&lt;BR /&gt;data covid;&lt;BR /&gt;set covid1k.covid1k;&lt;BR /&gt;format RACETHN 1= $YES&lt;BR /&gt;2= $NO;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc format AGE;&lt;BR /&gt;value AGEGROUP&lt;BR /&gt;1 = "0-4"&lt;BR /&gt;2 = "5-17"&lt;BR /&gt;3 = "18-49"&lt;BR /&gt;4 = "50-64"&lt;BR /&gt;5 = "≥65";&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc freq data = covid;&lt;BR /&gt;table HospDeath;&lt;BR /&gt;format HospDeath AGE.;&lt;BR /&gt;run;</description>
      <pubDate>Mon, 31 Jan 2022 03:49:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Sas-format-questions/m-p/793419#M38884</guid>
      <dc:creator>saza</dc:creator>
      <dc:date>2022-01-31T03:49:14Z</dc:date>
    </item>
  </channel>
</rss>

