<?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 count the frequency of variables that I have generated in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251805#M47640</link>
    <description>&lt;P&gt;There are various methods for generating tables, its likely your company has their own standards/macro libararies. &amp;nbsp;You can also find some examples in the PHUSE library:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/phuse-org/phuse-scripts/wiki/Standard-Script-Index" target="_blank"&gt;https://github.com/phuse-org/phuse-scripts/wiki/Standard-Script-Index&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without test data (as a datastep) its hard to provide code.&lt;/P&gt;</description>
    <pubDate>Tue, 23 Feb 2016 16:29:59 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-02-23T16:29:59Z</dc:date>
    <item>
      <title>how to count the frequency of variables that I have generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251803#M47638</link>
      <description>&lt;P&gt;This is a large dataset, including over 100k obs. What I need to do is to classify individuals into body system categories based on their icd-9 categories.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;For example, this is a sample code.&lt;BR /&gt;if substr(dx{i},1,3) in ('080', '081', '082'), then mar_head=1&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Therefore, I have generated 31 different categories.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;After that, I need to generate&amp;nbsp; a frequency table of this population, if that can be listed in an order based on the frequency of each different cateogory. For example, lung diseases is the first major problem; head diseases is the second most frequent problem. That is what I expect. Since it is a large dataset, and there are so many categories. I use transpose.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc transpose data=sam1 out=samid;&lt;BR /&gt;var mar_head--mar_gyne;&lt;BR /&gt;by id; run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I then have a table generated with newid, previousid, and the name of formal variable, including mar_head, mar_colon.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Then, I hope to get advice from you how to count the frequency of those variables, which is now listed under one column, called “name of formal variable”.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I want to have a following table:&lt;BR /&gt;Body system percent N&lt;BR /&gt;Musculoskeletal 26.2% 12345&lt;BR /&gt;Respiratory 25.5% 12322&lt;BR /&gt;Neurological 24.8% 11112&lt;BR /&gt;Mental health 18.6% 9687&lt;BR /&gt;Respiratory 14.6% 9456&lt;BR /&gt;Eye Diseases 4.4% 3233&lt;BR /&gt;Digestive 4.3% 2459&lt;BR /&gt;Gynecological 6.2% 4562&lt;BR /&gt;All Other 10.3% 5688&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I do not know how to do this. Also, I need to only count each individual once. Thank you for your advice&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 16:18:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251803#M47638</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-02-23T16:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of variables that I have generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251804#M47639</link>
      <description>&lt;P&gt;PROC FREQ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post some sample data and expected output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's easy to say count an individual once, but what does that mean? What happens when people have multiple issues-highly likely as a lot of issues are related.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 16:22:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251804#M47639</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-23T16:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of variables that I have generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251805#M47640</link>
      <description>&lt;P&gt;There are various methods for generating tables, its likely your company has their own standards/macro libararies. &amp;nbsp;You can also find some examples in the PHUSE library:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/phuse-org/phuse-scripts/wiki/Standard-Script-Index" target="_blank"&gt;https://github.com/phuse-org/phuse-scripts/wiki/Standard-Script-Index&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without test data (as a datastep) its hard to provide code.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 16:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251805#M47640</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-02-23T16:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of variables that I have generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251819#M47644</link>
      <description>&lt;P&gt;It looks like you are making indicator variables. &amp;nbsp;You can summarize the indicators directly to get N DENOM and PCT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mar;
   input id:$3. trt mar_head mar_gyne;
   cards;
001 1 . 1
001 1 0 1
001 1 0 1
002 2 . .
003 2 1 0
003 2 1 1 
004 1 . .
005 1 . .
;;;;
   run;
proc summary data=mar nway;
   class id trt;
   output out=max max(mar_:)=;
   run;
proc stdize missing=0 reponly data=max out=max0;
   var mar_:;
   run;

ods select none;
ods output Summary=Summary;
proc means data=max0 nway stackods sum n mean;
   class trt;
   var mar_:;
   run;
ods select all;
proc print label;
   format sum f5. mean percentn.;
   label n='Denom' sum='N' mean='Pct';
   run;
   &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1999iEF14FB7967B93B9B/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 17:35:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251819#M47644</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-02-23T17:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of variables that I have generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251827#M47646</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/40773"&gt;@Bal23﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another option would be not to create 31 indicator variables, but only one variable containing the body system code (e.g. 1, 2, ..., 31 with a format assigning the codes to body system names).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if substr(dx{i},1,3) in ('080', '081', '082') then bscode=8;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Without any intermediate datasets you can then obtain the desired counts and percentages using PROC SQL: &lt;FONT face="courier new,courier"&gt;count(distinct id)&lt;/FONT&gt; gives the number of individuals in the respective group. Your sample table (with percentages summing up to 134.9) indicates that overlaps between the body systems are anticipated. I assume that the percentages refer to some comprehensive dataset (called ALLIDS below) which may contain individuals who don't occur in any of the body system categories (like IDs 31 and 33 in the example below). If all of your individuals are classified, you can get the total from dataset HAVE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create sample data */

proc format;
value bscfmt
5='Musculoskeletal'
6='Neurological'
7='Respiratory'
31='All Other';
run;

data have;
bscode=5;
do id=1 to 20;
  output;
  if id&amp;gt;17 then output; /* IDs with 2 muscul. diseases */
end;
bscode=7;
do id=16 to 30;
  output;
end;
bscode=6;
do id=16 to 36 by 2;
  output;
end;
bscode=31;
do id=35 to 48;
  output;
end;
format bscode bscfmt.;
label bscode='Body system';
run;

data allids;
do id=1 to 48;
  output;
end;
run;

/* Perform counts and sort the results */

proc sql;
select count(distinct id) into :total 
from allids;

create table bscounts as
select bscode, count(distinct id) as N,
       calculated N/&amp;amp;total as percent format=percent8.1
from have
group by bscode
order by (bscode=31), N desc; /* This keeps category "All Other" at the end. */
quit;

proc print data=bscounts label noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 18:47:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251827#M47646</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-23T18:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of variables that I have generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251842#M47652</link>
      <description>&lt;P&gt;Thanks. What does "trt" stand for?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 20:05:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251842#M47652</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-02-23T20:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of variables that I have generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251843#M47653</link>
      <description>&lt;P&gt;Thank you very much. I like it. I have not tried yet, because I find there is something wrong with my code. That is, all these variables I generated, including mar_colon, mar_head, have value "0";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;would any of you suggest what that happens?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 20:08:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251843#M47653</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-02-23T20:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of variables that I have generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251846#M47654</link>
      <description>&lt;P&gt;In the IF/THEN statement in your initial post you had a comma between the condition and "then". If it's this, the log should contain error messages.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 20:15:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251846#M47654</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-23T20:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of variables that I have generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251847#M47655</link>
      <description>&lt;P&gt;You will need to show example program and data. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 20:15:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251847#M47655</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-02-23T20:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of variables that I have generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251871#M47670</link>
      <description>&lt;P&gt;no comma, no error message&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;below is the sample code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if substr(dx{i},1,2) in ('77')&lt;BR /&gt;&lt;BR /&gt;or substr(dx{i},1,6) in ('EYES -', 'EYES-G')&lt;BR /&gt;then do;&lt;BR /&gt;mar_eye=1;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc contents data=have;&lt;/P&gt;&lt;P&gt;run;&amp;nbsp; /*I realize I generate numerical variables, instead of categorical one that I prefer. Would you please let me know how to fix that as well?*/&lt;/P&gt;&lt;P&gt;proc means data=have;&lt;/P&gt;&lt;P&gt;var mar_:;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 21:10:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251871#M47670</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-02-23T21:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of variables that I have generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251876#M47673</link>
      <description>&lt;P&gt;Still too little information, for me to do anything but guess.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 21:20:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251876#M47673</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-02-23T21:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of variables that I have generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251878#M47675</link>
      <description>&lt;P&gt;There is no syntax error in your code provided that the array variables dx{i} are character variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You wrote that "&lt;SPAN&gt;&lt;EM&gt;all these variables&lt;/EM&gt;" mar_xxx have value 0. This means that there must be a substantial issue which should be easy to find: Just print an arbitrary dx{i} value from your dataset without formatting (&lt;FONT face="courier new,courier"&gt;format _all_;&lt;/FONT&gt;) and then check why the corresponding IF condition is not met. (Possible reasons include leading blanks, upper/lower case mismatch, formatted vs. unformatted values, ...)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 21:27:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/251878#M47675</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-23T21:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of variables that I have generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/252054#M47740</link>
      <description>&lt;P&gt;Thank you very much. I am sorry I do not understand it very well. Would you please explain a little bit more? Or give an example like a sample sas code&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do find some notes from the log&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Character values have been converted to numeric values at the places given by:&lt;BR /&gt;(Line):(Column).&lt;BR /&gt;2286:25 2653:12&lt;BR /&gt;NOTE: Numeric values have been converted to character values at the places given by:&lt;BR /&gt;(Line):(Column).&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 14:36:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/252054#M47740</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-02-24T14:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of variables that I have generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/252065#M47745</link>
      <description>&lt;P&gt;These automatic conversion messages can be harmless in some cases and indicate serious issues in others. Therefore, I recommend to avoid them whenever possible by performing the conversions explicitly:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;numeric to character typically by means of the PUT function (and a format as the second function argument)&lt;/LI&gt;
&lt;LI&gt;character to numeric typically &lt;SPAN&gt;by means of &lt;/SPAN&gt;the INPUT function&lt;SPAN&gt; (and an informat as the second function argument).&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Regarding the ICD-9 codes, all you have shown so far are those IF conditions involving applications of the SUBSTR function to array elements dx{i}. Array elements, however, are valid references only during a data step where the array is defined. So, the real names of the variables&amp;nbsp;you referred to as dx{i} could be dx1, dx2 etc., but could be completely different as well, e.g. icdcode_BL, icdcode_wk4, ....&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please just look up some of the said real names from the array statement, let us know of what type and length these variables are (see PROC CONTENTS output for the dataset the variables belong to) and print a few unformatted values of these variables:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=have(obs=5);
format _all_;
var dx1 dx2 icdcode_BL; /* or whatever the real names are */
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 15:09:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/252065#M47745</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-24T15:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of variables that I have generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/252069#M47747</link>
      <description>&lt;P&gt;Proc contents&lt;/P&gt;&lt;P&gt;they are all numerical, with length of 8&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;print&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;have&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;obs&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;5&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;format&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;_all_&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;var&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;dx&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;dx&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2&lt;/SPAN&gt; icdcode_BL&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;SPAN class="token comment"&gt;/* or whatever the real names are */&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did run this, the values of all those var are missing&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 15:21:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/252069#M47747</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-02-24T15:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of variables that I have generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/252073#M47751</link>
      <description>&lt;P&gt;I assume&amp;nbsp;that&amp;nbsp;you replaced my guessed dummy names dx1, dx2, icdcode_BL by &lt;EM&gt;your&lt;/EM&gt; variable names before running the PROC PRINT step (otherwise, you'd have received error messages like "ERROR: Variable DX1 not found." and not even missing values).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the important information that the variables are numeric. Hence, you cannot apply a character function such as SUBSTR to these variables. Did the PROC CONTENTS output contain a column headed&amp;nbsp;"Format"? If yes, what did it contain for the variables ("dx1" etc.) in question?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 15:41:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/252073#M47751</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-24T15:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of variables that I have generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/252082#M47755</link>
      <description>&lt;P&gt;Thank you for explaining.&lt;/P&gt;&lt;P&gt;I first check proc contents on the dataset I generated&lt;/P&gt;&lt;P&gt;I did not see any error message. There is a format column, only one variable does have info (that is not the variables that we are talking about). All those variables that I am talking about have blank info regarding :format&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I run proc contents on the dataset I have. Dx vars are char and have the length of 5. I do not know why when I use this if then, the variables I generated become numerical.&lt;/P&gt;&lt;P&gt;dx1 Char 5&lt;BR /&gt;7 dx2 Char 5&lt;BR /&gt;8 dx3 Char 5&lt;BR /&gt;9 dx4 Char 5&lt;BR /&gt;10 dx5 Char 5&lt;BR /&gt;11 dx6 Char 5&lt;BR /&gt;12 dx7 Char 5&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 16:37:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/252082#M47755</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-02-24T16:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of variables that I have generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/252086#M47757</link>
      <description>&lt;P&gt;Good to know that your dx&lt;EM&gt;i&lt;/EM&gt; variables are character and their names are dx1, dx2 etc. If you code &lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;mar_head=1;&lt;/FONT&gt;&amp;nbsp;SAS will indeed create a numeric variable. The value 1 is obviously numeric, so a numeric variable seems to be most appropriate. If you want character variables mar_xxxx whose possible values are only '0', '1' or missing (i.e. ' '), the assignment statements should have the form &lt;FONT face="courier new,courier"&gt;mar_head='1';&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;We haven't found out yet, why all of the mar_xxxx variables received value 0. To gain some insight into the dx1 values, please post the output of the PROC PRINT&amp;nbsp;step below:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have order=freq noprint;
tables dx1 / out=cnt;
run;

proc print data=cnt(obs=5);
format dx1 $hex10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 17:10:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/252086#M47757</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-24T17:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of variables that I have generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/252088#M47759</link>
      <description>&lt;P&gt;Obs dx1 COUNT PERCENT&lt;BR /&gt;1 2020202020 2237 .&lt;BR /&gt;2 3336373220 8541 6.11084&lt;BR /&gt;3 3338392020 6275 4.48958&lt;BR /&gt;4 3336373120 5373 3.84423&lt;BR /&gt;5 3939352020 4622 3.30691&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 17:15:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/252088#M47759</guid>
      <dc:creator>Bal23</dc:creator>
      <dc:date>2016-02-24T17:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to count the frequency of variables that I have generated</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/252097#M47766</link>
      <description>&lt;P&gt;Great, thanks. So, the most frequent value of&amp;nbsp;dx1 is '3672'. Which of the mar_xxxx variables would you have expected to get value 1 given this dx1 value?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's say, your answer would be: mar_eye. Then, what does the IF condition look like in the statement that ends with "... &lt;FONT face="courier new,courier"&gt;then mar_eye=1;&lt;/FONT&gt;"?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 17:35:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-count-the-frequency-of-variables-that-I-have-generated/m-p/252097#M47766</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-02-24T17:35:27Z</dc:date>
    </item>
  </channel>
</rss>

