<?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: Creating group data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500852#M133439</link>
    <description>&lt;P&gt;Sorry, I was not precise enough. Please post the log from that step. Use the {i} icon.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Oct 2018 17:15:02 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-10-02T17:15:02Z</dc:date>
    <item>
      <title>Creating group data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500840#M133412</link>
      <description>&lt;P&gt;So I have 7 different subsets of a SAS data sets. I am trying&amp;nbsp;&lt;/P&gt;&lt;P&gt;to create a program that concatenation these 7 data sets into&amp;nbsp;&lt;/P&gt;&lt;P&gt;one data set and then create an age group variable with&amp;nbsp;&lt;/P&gt;&lt;P&gt;categories 35-44, 45-54, 55-64, 65-74, &amp;gt;=75.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following shows the code I used:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc format;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Value agegrp low-35=“&amp;lt;35”&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 35-44=“35-44”&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 45-54=“45-54”&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;55-64=“55-64”&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;65-74=“65-74”&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;75-high=“75+”;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Libname in “E:\locationofsas”;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data chapter19;&lt;/P&gt;&lt;P&gt;set in.ch19a in.ch19b in.ch19c in.ch19d in.ch19e in.ch19f&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; in.ch19g;&lt;/P&gt;&lt;P&gt;format agegrp agegrp.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print;&lt;/P&gt;&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried running this and the new column created for age group&lt;/P&gt;&lt;P&gt;is filled with “.”. It is blank. How do I create a new age group?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 17:00:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500840#M133412</guid>
      <dc:creator>JUMMY</dc:creator>
      <dc:date>2018-10-02T17:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: Creating group data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500844#M133414</link>
      <description>&lt;P&gt;What does the log from that data step say?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 17:07:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500844#M133414</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-02T17:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: Creating group data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500846#M133415</link>
      <description>&lt;P&gt;May be you need this&lt;/P&gt;
&lt;P&gt;Assuming you have a numeric variable age and want to create a new char variable agegroup&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data chapter19;&lt;/P&gt;
&lt;P&gt;set in.ch19a in.ch19b in.ch19c in.ch19d in.ch19e in.ch19f&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; in.ch19g;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;agegrp=put(age,agegrp.); /*I think this is what you want*/&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;format age agegrp.;/*apply format for numeric variable age if you want*/&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;proc print;&lt;/P&gt;
&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 17:08:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500846#M133415</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-02T17:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: Creating group data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500847#M133416</link>
      <description>&lt;P&gt;I suspect the problem comes in that you don't seem to have a variable called agegrp in your dataset. I suspect that you probably have a variable called age.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By applying the format to age instead, the format will show in your dataset, but the numeric value will still be kept so you can perform calculations etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to create groups using a format, you could within your datastep include a statement such as the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AGEGRP = put(age, agegrp.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 17:09:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500847#M133416</guid>
      <dc:creator>Karen_Horton</dc:creator>
      <dc:date>2018-10-02T17:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: Creating group data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500848#M133417</link>
      <description>&lt;P&gt;Create new variable using PUT()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;agegrp=put(age,agegrp.);&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 17:10:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500848#M133417</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-10-02T17:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: Creating group data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500849#M133418</link>
      <description>&lt;P&gt;The log says “successfully”. How do I correct the series of dots created&lt;/P&gt;&lt;P&gt;in the new column?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 17:11:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500849#M133418</guid>
      <dc:creator>JUMMY</dc:creator>
      <dc:date>2018-10-02T17:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: Creating group data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500851#M133438</link>
      <description>&lt;P&gt;Format need to be applied to columns that already exist in the dataset or the new columns that are created. Does your input data have agegrp column already? If not then you will get all missing values with column created. Define it first using the PUT() function.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 17:15:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500851#M133438</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-10-02T17:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: Creating group data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500852#M133439</link>
      <description>&lt;P&gt;Sorry, I was not precise enough. Please post the log from that step. Use the {i} icon.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 17:15:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500852#M133439</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-02T17:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: Creating group data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500854#M133440</link>
      <description>&lt;P&gt;The put function solution has been suggested twice in the same thread by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/225320"&gt;@Karen_Horton&lt;/a&gt;. Doesn't really help or make much difference in duplicating the same solution. For the benefit of wider community, I request to you kindly offer new alternatives rather. My 2 cents &amp;amp; Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 17:18:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500854#M133440</guid>
      <dc:creator>CharlotteCain</dc:creator>
      <dc:date>2018-10-02T17:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: Creating group data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500855#M133441</link>
      <description>It was actually posted within seconds of each other. Can’t help if great minds think a like.&lt;BR /&gt;</description>
      <pubDate>Tue, 02 Oct 2018 17:20:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500855#M133441</guid>
      <dc:creator>Karen_Horton</dc:creator>
      <dc:date>2018-10-02T17:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: Creating group data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500859#M133442</link>
      <description>&lt;P&gt;A small matter, since you already received advice on the bigger issue ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your format defines 35 exactly as being "&amp;lt;35".&amp;nbsp; You may want to adjust either the ranges or the labels.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 17:37:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500859#M133442</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-10-02T17:37:23Z</dc:date>
    </item>
    <item>
      <title>Re: Creating group data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500877#M133452</link>
      <description>&lt;P&gt;As an alternative(FWIW), you can store the agegroup in a dataset&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Start $ end  $ label $ hlo $;
retain Fmtname 'agegroup'     Type 'N';
cards;
low 35 &amp;lt;35 L
35 44  35-44 .
45 54 45-54 .
55 64 55-64 .
65 74 65-74 .
75 high 75+ H
;

proc format cntlin=have fmtlib;
run;

data want;
do age=0 to 100;
agegroup=put(age,agegroup.);
output;
end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Oct 2018 18:09:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500877#M133452</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-02T18:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: Creating group data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500963#M133492</link>
      <description>How do I define the ranges? I suspect that is where the error is?</description>
      <pubDate>Tue, 02 Oct 2018 20:59:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/500963#M133492</guid>
      <dc:creator>JUMMY</dc:creator>
      <dc:date>2018-10-02T20:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: Creating group data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/501034#M133536</link>
      <description>&lt;P&gt;You had an ambiguity for the value 35 in your format, so it needs to be corrected:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value agegrp
  low-34="&amp;lt;35"
  35-44="35-44"
  45-54="45-54"
  55-64="55-64"
  65-74="65-74"
  75-high="75+"
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your code, as posted, would not run, because it hat UTF quotes in it. I suspect you committed the (not so rare) mistake of moving your code through a word processor program (eg MS Word) at one stage. Don't do that, us only pure text editors like the editor in SAS or notepad++.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And use the proper windows for posting programming-related text here on the communities. Use the {i} button for logs and other textual data like snippets from csv files. The "little running man" icon gives you a window that adds coloring similar to the SAS Enhanced Editor.&lt;/P&gt;
&lt;P&gt;Both windows will preserve the text as-is, inlcuding horizontal spacings. The main posting window will trash that, replace certain sequences with smileys, and so on.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Oct 2018 06:37:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-group-data/m-p/501034#M133536</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-03T06:37:48Z</dc:date>
    </item>
  </channel>
</rss>

