<?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 Create a New Variable Based on Frequency in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599409#M173028</link>
    <description>&lt;P&gt;I need help creating a variable for number enrolled.&amp;nbsp; I need a table that has&lt;/P&gt;&lt;P&gt;siteID siteName number enrolled.&amp;nbsp; &amp;nbsp;How can I create a variable that will count each patient so the frequencies turn out correctly?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Fri, 25 Oct 2019 17:00:12 GMT</pubDate>
    <dc:creator>heatherjae15</dc:creator>
    <dc:date>2019-10-25T17:00:12Z</dc:date>
    <item>
      <title>Re: How to Create a New Variable Based on Frequency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599409#M173028</link>
      <description>&lt;P&gt;I need help creating a variable for number enrolled.&amp;nbsp; I need a table that has&lt;/P&gt;&lt;P&gt;siteID siteName number enrolled.&amp;nbsp; &amp;nbsp;How can I create a variable that will count each patient so the frequencies turn out correctly?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 17:00:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599409#M173028</guid>
      <dc:creator>heatherjae15</dc:creator>
      <dc:date>2019-10-25T17:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create a New Variable Based on Frequency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599410#M173029</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/296840"&gt;@heatherjae15&lt;/a&gt;&amp;nbsp;Hi and welcome to the SAS Community.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you able to post some example of what your data looks like along with the desired result based on that data? Makes it much easier to provide a usable code answer.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 17:11:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599410#M173029</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-25T17:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create a New Variable Based on Frequency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599411#M173030</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*This demonstrates how to count the number of unique occurences of a variable
across groups. It uses the SASHELP.CARS dataset which is available with any SAS installation.
The objective is to determine the number of unique car makers by origin/
Note: The SQL solution can be off if you have a large data set and these are not the only two ways to calculate distinct counts.
If you're dealing with a large data set other methods may be appropriate.*/

*Count distinct IDs;
proc sql;
create table distinct_sql as
select origin, count(distinct make) as n_make
from sashelp.cars
group by origin;
quit;

*Double PROC FREQ;
proc freq data=sashelp.cars noprint;
table origin * make / out=origin_make;
run;

proc freq data=origin_make noprint;
table origin / out= distinct_freq;
run;

title 'PROC FREQ';
proc print data=distinct_freq;
run;
title 'PROC SQL';
proc print data=distinct_sql;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/count_distinct_by_group.sas" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/count_distinct_by_group.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/296840"&gt;@heatherjae15&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I need help creating a variable for number enrolled.&amp;nbsp; I need a table that has&lt;/P&gt;
&lt;P&gt;siteID siteName number enrolled.&amp;nbsp; &amp;nbsp;How can I create a variable that will count each patient so the frequencies turn out correctly?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 17:13:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599411#M173030</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-25T17:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create a New Variable Based on Frequency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599418#M173034</link>
      <description>I cant post the data. I currently have sitename and siteId. I need to make a table that shows siteID, sitename and enrolled subjects. so it is a 3 column table with the siteid sitename and number of enrolled subjects.</description>
      <pubDate>Fri, 25 Oct 2019 17:38:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599418#M173034</guid>
      <dc:creator>heatherjae15</dc:creator>
      <dc:date>2019-10-25T17:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create a New Variable Based on Frequency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599419#M173035</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/296840"&gt;@heatherjae15&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I cant post the data. I currently have sitename and siteId. I need to make a table that shows siteID, sitename and enrolled subjects. so it is a 3 column table with the siteid sitename and number of enrolled subjects.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Don't post actual sensible data. Make up a few observations with fake data, just enough to illustrate your issue. Post as data step with datalines.&lt;/P&gt;
&lt;P&gt;Don't force us to make guesses, help us to help you.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 17:43:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599419#M173035</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-25T17:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create a New Variable Based on Frequency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599420#M173036</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/296840"&gt;@heatherjae15&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I cant post the data. I currently have sitename and siteId. I need to make a table that shows siteID, sitename and enrolled subjects. so it is a 3 column table with the siteid sitename and number of enrolled subjects.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have;
    table sitename*siteid/list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This implies that the input data has one record per patient. If that's not the case, then you need to state more about how the data is organized, and follow the advice of&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;above.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 17:46:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599420#M173036</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-10-25T17:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create a New Variable Based on Frequency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599422#M173037</link>
      <description>This creates a diagonal. I just want the variables siteID sitename with&lt;BR /&gt;the number of pts enrolled&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Oct 2019 17:51:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599422#M173037</guid>
      <dc:creator>heatherjae15</dc:creator>
      <dc:date>2019-10-25T17:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create a New Variable Based on Frequency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599423#M173038</link>
      <description>&lt;P&gt;You need the LIST option, as I showed in my code.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 18:01:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599423#M173038</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-10-25T18:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create a New Variable Based on Frequency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599426#M173040</link>
      <description>Ohhh, thank you</description>
      <pubDate>Fri, 25 Oct 2019 18:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599426#M173040</guid>
      <dc:creator>heatherjae15</dc:creator>
      <dc:date>2019-10-25T18:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create a New Variable Based on Frequency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599428#M173041</link>
      <description>Paige, I am getting an error that says it can't find my data. Any thoughts?</description>
      <pubDate>Fri, 25 Oct 2019 18:30:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599428#M173041</guid>
      <dc:creator>heatherjae15</dc:creator>
      <dc:date>2019-10-25T18:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create a New Variable Based on Frequency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599429#M173042</link>
      <description>&lt;P&gt;show us the LOG from your code, not just the ERROR messages, but the code as it appears in the log, plus the error messages.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please click on the &lt;FONT face="courier new,courier"&gt;{i}&lt;/FONT&gt; icon and paste the log AS TEXT into the window that appears.&amp;nbsp;&lt;STRONG&gt;Do not skip this step.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 18:32:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599429#M173042</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-10-25T18:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create a New Variable Based on Frequency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599430#M173043</link>
      <description>I fixed that now how do I remove the percent, cum frequency and cum percent?</description>
      <pubDate>Fri, 25 Oct 2019 18:32:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599430#M173043</guid>
      <dc:creator>heatherjae15</dc:creator>
      <dc:date>2019-10-25T18:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create a New Variable Based on Frequency</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599433#M173044</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/296840"&gt;@heatherjae15&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I fixed that now how do I remove the percent, cum frequency and cum percent?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have;
    table sitename*siteid/list nocum nopercent;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You might want to look at the PROC FREQ documentation to see the wide variety of options available.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=procstat&amp;amp;docsetTarget=procstat_freq_toc.htm&amp;amp;locale=en"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=procstat&amp;amp;docsetTarget=procstat_freq_toc.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 18:36:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-Create-a-New-Variable-Based-on-Frequency/m-p/599433#M173044</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-10-25T18:36:43Z</dc:date>
    </item>
  </channel>
</rss>

