<?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: Recoding a string variable --&amp;gt; most frequent category has largest value in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Recoding-a-string-variable-gt-most-frequent-category-has-largest/m-p/1687#M758</link>
    <description>Thank you! I'll post it there.&lt;BR /&gt;
Claudai</description>
    <pubDate>Wed, 01 Nov 2006 21:25:59 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2006-11-01T21:25:59Z</dc:date>
    <item>
      <title>Recoding a string variable --&gt; most frequent category has largest value</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Recoding-a-string-variable-gt-most-frequent-category-has-largest/m-p/1685#M756</link>
      <description>Hi there,&lt;BR /&gt;
&lt;BR /&gt;
I have a question about coding values of a variable. I have split this into two parts as it would be helpful to me even if I could only get an answer to the first part.  Thanks ahead of time for any light anyone is able to shed on this!&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
/** DATA SAMPLE **/&lt;BR /&gt;
I have hundreds of string variables with over a thousand observations for each.&lt;BR /&gt;
Sample Data&lt;BR /&gt;
VAR1                    VAR2	&lt;BR /&gt;
CC     freq = 494        GG     freq = 3000&lt;BR /&gt;
CT     freq = 29         GT     freq = 185&lt;BR /&gt;
TT     freq = 1          TT     freq = 39&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
/** PART A **/&lt;BR /&gt;
I need to convert the strings to numerals while simultaneously setting the largest (most frequent) category to the largest value. Ultimately, this is so I can use catmod for polytomous regression and get the correct reference categories. (These are all independent variables, I have been able to set the correct reference category for the dependent variable.) &lt;BR /&gt;
&lt;BR /&gt;
Is there a function that will do this for me? &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
/** PART B  **/&lt;BR /&gt;
&lt;BR /&gt;
and how can I integrate that into a macro?&lt;BR /&gt;
&lt;BR /&gt;
Here is the macro I am using at the moment: &lt;BR /&gt;
%macro bob;	&lt;BR /&gt;
%let varnum = 1;&lt;BR /&gt;
%let var = %scan(&amp;amp;varlist, &amp;amp;varnum);&lt;BR /&gt;
%do %while (%length(&amp;amp;var) ne 0);&lt;BR /&gt;
			&lt;BR /&gt;
	title ;&lt;BR /&gt;
	ods listing close;&lt;BR /&gt;
	proc catmod  data=cox2  ;&lt;BR /&gt;
		direct X  ;&lt;BR /&gt;
		model dep_var = X &amp;amp;var ;&lt;BR /&gt;
		ods output Estimates = model_&amp;amp;var ;&lt;BR /&gt;
	run;&lt;BR /&gt;
	quit;&lt;BR /&gt;
	ods listing;&lt;BR /&gt;
&lt;BR /&gt;
/** I am then using PROC REPORT to recover outputs **/&lt;BR /&gt;
/** I am interested in. These lines have been      **/&lt;BR /&gt;
/** omitted from this example			   **/&lt;BR /&gt;
&lt;BR /&gt;
	%let varnum = %eval(&amp;amp;varnum + 1);&lt;BR /&gt;
	%let var = %scan(&amp;amp;varlist, &amp;amp;varnum);&lt;BR /&gt;
  %put &amp;amp;varnum &amp;amp;var;&lt;BR /&gt;
  %end;&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
I have tried the "order =" option in catmod, but haven't found it to be useful in this case. &lt;BR /&gt;
&lt;BR /&gt;
thank you!&lt;BR /&gt;
&lt;BR /&gt;
Claudia

&lt;BR /&gt;
Message was edited by: CAS at Oct 31, 2006 3:33 AM -- to make data sample easier to read&lt;BR /&gt;</description>
      <pubDate>Tue, 31 Oct 2006 08:31:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Recoding-a-string-variable-gt-most-frequent-category-has-largest/m-p/1685#M756</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2006-10-31T08:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding a string variable --&gt; most frequent category has largest value</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Recoding-a-string-variable-gt-most-frequent-category-has-largest/m-p/1686#M757</link>
      <description>This question is perhaps best answered by Technical Support.  You can submit it online at &lt;A href="http://support.sas.com/ctx/supportform/index.jsp" target="_blank"&gt;http://support.sas.com/ctx/supportform/index.jsp&lt;/A&gt; .&lt;BR /&gt;
&lt;BR /&gt;
-- David Kelley, SAS</description>
      <pubDate>Wed, 01 Nov 2006 18:52:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Recoding-a-string-variable-gt-most-frequent-category-has-largest/m-p/1686#M757</guid>
      <dc:creator>David_SAS</dc:creator>
      <dc:date>2006-11-01T18:52:53Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding a string variable --&gt; most frequent category has largest value</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Recoding-a-string-variable-gt-most-frequent-category-has-largest/m-p/1687#M758</link>
      <description>Thank you! I'll post it there.&lt;BR /&gt;
Claudai</description>
      <pubDate>Wed, 01 Nov 2006 21:25:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Recoding-a-string-variable-gt-most-frequent-category-has-largest/m-p/1687#M758</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2006-11-01T21:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding a string variable --&gt; most frequent category has largest value</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Recoding-a-string-variable-gt-most-frequent-category-has-largest/m-p/1688#M759</link>
      <description>Apart from using the LOGISTIC procedure instead of CATMOD, which may lead you to find the ORDER=FREQ option useful, I suggest that kind of trick :&lt;BR /&gt;
&lt;BR /&gt;
1) PROC FREQ ORDER=FREQ your data according to the chosen variable (the one to recode), then save results with ODS OUTPUT oneWayFreqs = work.myValues ;&lt;BR /&gt;
2) Sort MyValues By DESCENDING variable, then with a DATA step, re-read the MyValues dataset to add a new variable, recoded=_N_, to it ;&lt;BR /&gt;
3) Merge MyValues with your core data BY the chosen variable&lt;BR /&gt;
4) use recoded as input for your modelling procedure.&lt;BR /&gt;
&lt;BR /&gt;
This can be performed for each variable in your macro, even if it may be time-consuming to re-FREQ the whole dataset, then re-merge it, at each loop.&lt;BR /&gt;
&lt;BR /&gt;
Regards.&lt;BR /&gt;
Olivier</description>
      <pubDate>Thu, 02 Nov 2006 12:19:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Recoding-a-string-variable-gt-most-frequent-category-has-largest/m-p/1688#M759</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2006-11-02T12:19:06Z</dc:date>
    </item>
  </channel>
</rss>

