<?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: Adding observations in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Adding-observations/m-p/7714#M166</link>
    <description>You could use dataview\edit mode\insert row, but impractical for datasets with more than 5-6 variables.</description>
    <pubDate>Mon, 23 Jun 2008 16:59:31 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-06-23T16:59:31Z</dc:date>
    <item>
      <title>Adding observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-observations/m-p/7706#M158</link>
      <description>Can we add new observations to a dataset, not by using merge option or set statements and Proc Append?</description>
      <pubDate>Wed, 26 Mar 2008 06:26:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-observations/m-p/7706#M158</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-03-26T06:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Adding observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-observations/m-p/7707#M159</link>
      <description>You can do it interactively in PROC FSEDIT or in Enterprise Guide.</description>
      <pubDate>Wed, 26 Mar 2008 13:27:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-observations/m-p/7707#M159</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2008-03-26T13:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: Adding observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-observations/m-p/7708#M160</link>
      <description>...And with PROC SQL INSERT INTO.&lt;BR /&gt;
cynthia</description>
      <pubDate>Wed, 26 Mar 2008 14:58:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-observations/m-p/7708#M160</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-03-26T14:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: Adding observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-observations/m-p/7709#M161</link>
      <description>Hi,&lt;BR /&gt;
       &lt;BR /&gt;
      Thanks for reply.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Bye.</description>
      <pubDate>Mon, 31 Mar 2008 07:55:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-observations/m-p/7709#M161</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-03-31T07:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: Adding observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-observations/m-p/7710#M162</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
        Thanks for reply. Actually my dataset is like below&lt;BR /&gt;
col1	col2	col3&lt;BR /&gt;
1	x1	a1&lt;BR /&gt;
2	x1	a2&lt;BR /&gt;
3	x2	b1&lt;BR /&gt;
4	x2	b2&lt;BR /&gt;
5	x3	c1&lt;BR /&gt;
6	x3	c2&lt;BR /&gt;
&lt;BR /&gt;
and i want to add labels like below with out creating new datasets for labels and not by using merge stmt or Proc Append....&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
col	col2	col3&lt;BR /&gt;
'A Group'&lt;BR /&gt;
1	x1	a1&lt;BR /&gt;
2	x1	a2&lt;BR /&gt;
'B Group'&lt;BR /&gt;
3	x2	b1&lt;BR /&gt;
4	x2	b2&lt;BR /&gt;
'C Group'&lt;BR /&gt;
5	x3	c1&lt;BR /&gt;
6	x3	c2&lt;BR /&gt;
&lt;BR /&gt;
Thank You.</description>
      <pubDate>Mon, 31 Mar 2008 08:00:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-observations/m-p/7710#M162</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-03-31T08:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: Adding observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-observations/m-p/7711#M163</link>
      <description>Hi:&lt;BR /&gt;
  This looks like a report writing task, and not something you'd store permanently in the data set. Just one reason why would wouldn't insert a variable like that into your dataset is that it looks like you want the variable "row" to "span" all 3 columns, like something you'd do in Excel. But, SAS expects every data set "row" to have the same number of columns -- so you could only insert a "spanning" row like this into a report -- not into the data set itself.&lt;BR /&gt;
&lt;BR /&gt;
If your data were stored in a file called PERM.MYDATA, then a PROC REPORT program like this would work on a temporary data set that created variable called 'Grp' to print the identifying row above each group:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data makegrp;&lt;BR /&gt;
  set perm.mydata;&lt;BR /&gt;
  Grp = catx(' ',upcase(substr(col3,1,1)),'Group');&lt;BR /&gt;
run;&lt;BR /&gt;
     &lt;BR /&gt;
ods listing;&lt;BR /&gt;
ods html file='c:\temp\makegrp.html' style=sasweb;&lt;BR /&gt;
proc report data=makegrp nowd;&lt;BR /&gt;
  column Grp col1 col2 col3;&lt;BR /&gt;
  define Grp / order noprint;&lt;BR /&gt;
  define col1 / display;&lt;BR /&gt;
  define col2 / display;&lt;BR /&gt;
  define col3 / display;&lt;BR /&gt;
  compute before Grp;&lt;BR /&gt;
    line Grp $10.;&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
ods html close;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Once your SAS session is over, the WORK.MAKEGRP file will go away and your original dataset is unchanged.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 31 Mar 2008 14:40:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-observations/m-p/7711#M163</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-03-31T14:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: Adding observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-observations/m-p/7712#M164</link>
      <description>Hi Cynthia,&lt;BR /&gt;
            In this case the labels are Uniform (A Group,B Group,,C Group,) ,if the labels are of different strings,for example &lt;BR /&gt;
CATEGORY       COUNT&lt;BR /&gt;
Gender&lt;BR /&gt;
male             12&lt;BR /&gt;
female          10&lt;BR /&gt;
&lt;BR /&gt;
Race &lt;BR /&gt;
asian                       12&lt;BR /&gt;
black or african        10&lt;BR /&gt;
american                 20&lt;BR /&gt;
&lt;BR /&gt;
Ethnicity&lt;BR /&gt;
Hispanic or Latino     11&lt;BR /&gt;
not Hispanic or Latino 10&lt;BR /&gt;
&lt;BR /&gt;
in the above example CATEGORY and COUNT are variables and Gender,Race and Ethnicity are labels,these labels are not present in dataset and they are completely arbitary.Then how to insert these labels in the report.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thank you.</description>
      <pubDate>Tue, 01 Apr 2008 04:37:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-observations/m-p/7712#M164</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-04-01T04:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: Adding observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-observations/m-p/7713#M165</link>
      <description>Hi:&lt;BR /&gt;
  The report you describe looks like a demographic report. I'll come back to that in a minute.&lt;BR /&gt;
&lt;BR /&gt;
  The code that I posted above uses a variable, the GRP variable in order to establish a break point in the program where I can write out text. "Label" to me, is what controls the column header -- the words "Category" or "Count" in your example. What I illustrated above was writing out a custom text line at a break point using a LINE statement.&lt;BR /&gt;
&lt;BR /&gt;
  For the kind of report you describe, I'd be very tempted to use PROC FREQ, which could give you this in LISTING destination:&lt;BR /&gt;
[pre]&lt;BR /&gt;
Proc Freq Method&lt;BR /&gt;
     &lt;BR /&gt;
Gender    Frequency&lt;BR /&gt;
-------------------&lt;BR /&gt;
Female           9&lt;BR /&gt;
Male            10&lt;BR /&gt;
    &lt;BR /&gt;
   &lt;BR /&gt;
Ethnic                    Frequency&lt;BR /&gt;
-----------------------------------&lt;BR /&gt;
Hispanic or Latino              12&lt;BR /&gt;
not Hispanic or Latino           7&lt;BR /&gt;
    &lt;BR /&gt;
[/pre]&lt;BR /&gt;
  &lt;BR /&gt;
or PROC TABULATE, which could give you this in LISTING destination:&lt;BR /&gt;
[pre]&lt;BR /&gt;
Proc Tabulate Method&lt;BR /&gt;
    &lt;BR /&gt;
--------------------------------&lt;BR /&gt;
|Category               |Count |&lt;BR /&gt;
|-----------------------+------|&lt;BR /&gt;
|Total Population       |    19|&lt;BR /&gt;
|-----------------------+------|&lt;BR /&gt;
|Gender                 |      |&lt;BR /&gt;
|-----------------------|      |&lt;BR /&gt;
|Female                 |     9|&lt;BR /&gt;
|-----------------------+------|&lt;BR /&gt;
|Male                   |    10|&lt;BR /&gt;
|-----------------------+------|&lt;BR /&gt;
|Ethnicity              |      |&lt;BR /&gt;
|-----------------------|      |&lt;BR /&gt;
|Hispanic or Latino     |    12|&lt;BR /&gt;
|-----------------------+------|&lt;BR /&gt;
|not Hispanic or Latino |     7|&lt;BR /&gt;
--------------------------------&lt;BR /&gt;
      &lt;BR /&gt;
[/pre]&lt;BR /&gt;
           &lt;BR /&gt;
Or use PROC REPORT. The difference between PROC FREQ and PROC TABULATE and PROC REPORT methods is that for PROC REPORT you need to summarize the data with another procedure (I used TABULATE to create a summarized data set) and -then- use this second data set with PROC REPORT to create this output:&lt;BR /&gt;
[pre]&lt;BR /&gt;
Proc Report on data set from proc tabulate&lt;BR /&gt;
Use NOPRINT on columns to hide them&lt;BR /&gt;
     &lt;BR /&gt;
  Category                       Count&lt;BR /&gt;
           Total Population&lt;BR /&gt;
  N                                 19&lt;BR /&gt;
         &lt;BR /&gt;
                Gender&lt;BR /&gt;
  Female                             9&lt;BR /&gt;
  Male                              10&lt;BR /&gt;
     &lt;BR /&gt;
              Ethnicity&lt;BR /&gt;
  Hispanic or Latino                12&lt;BR /&gt;
  not Hispanic or Latino             7&lt;BR /&gt;
    &lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
I used SASHELP.CLASS and made up a GENDER and an ETHNIC variable. The code I ran is below.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
 &lt;BR /&gt;
[pre]&lt;BR /&gt;
data testdata;&lt;BR /&gt;
  length Gender $6 Ethnic $25;&lt;BR /&gt;
  set sashelp.class;&lt;BR /&gt;
  if sex = 'M' then gender = 'Male';&lt;BR /&gt;
    else if sex = 'F' then gender = 'Female';&lt;BR /&gt;
  if age gt 12 then ethnic = 'Hispanic or Latino';&lt;BR /&gt;
    else ethnic =  'not Hispanic or Latino';&lt;BR /&gt;
run;&lt;BR /&gt;
    &lt;BR /&gt;
options nocenter nodate nonumber formchar='|----|+|--- ';&lt;BR /&gt;
ods listing;&lt;BR /&gt;
ods noptitle;&lt;BR /&gt;
ods html file='c:\temp\category.html' style=sasweb;&lt;BR /&gt;
      &lt;BR /&gt;
proc freq data=testdata;&lt;BR /&gt;
  title 'Proc Freq Method';&lt;BR /&gt;
  tables Gender Ethnic / nocum nopercent;&lt;BR /&gt;
  label gender = ' '&lt;BR /&gt;
        ethnic = ' ';&lt;BR /&gt;
run;&lt;BR /&gt;
      &lt;BR /&gt;
ods output table=work.tabout(rename=(n=count));&lt;BR /&gt;
proc tabulate data=testdata f=6.;&lt;BR /&gt;
  title 'Proc Tabulate Method';&lt;BR /&gt;
  class gender ethnic;&lt;BR /&gt;
  table all gender ethnic,n /&lt;BR /&gt;
        box = 'Category' rts=25;&lt;BR /&gt;
  keylabel N='Count'&lt;BR /&gt;
           All = 'Total Population';&lt;BR /&gt;
  label gender = 'Gender'&lt;BR /&gt;
        ethnic = 'Ethnicity';&lt;BR /&gt;
run;&lt;BR /&gt;
    &lt;BR /&gt;
proc print data=work.tabout;&lt;BR /&gt;
  title 'Summary data set from proc tabulate';&lt;BR /&gt;
run;&lt;BR /&gt;
       &lt;BR /&gt;
** to see what all the columns look like, remove the NOPRINT;&lt;BR /&gt;
** option from _type_, gender and ethnic;&lt;BR /&gt;
proc report data=work.tabout nowd missing&lt;BR /&gt;
  style(lines)={just=left};&lt;BR /&gt;
  title 'Proc Report on data set from proc tabulate';&lt;BR /&gt;
  title2 'Use NOPRINT on columns to hide them';&lt;BR /&gt;
  column _type_ gender ethnic category count;&lt;BR /&gt;
  define _type_ / order order=data 'Type' noprint;&lt;BR /&gt;
  define gender / order noprint;&lt;BR /&gt;
  define ethnic / order noprint;&lt;BR /&gt;
  define category / computed 'Category';&lt;BR /&gt;
  define count / display 'Count';&lt;BR /&gt;
  compute category / character length = 25;&lt;BR /&gt;
     if ethnic = ' ' and gender = ' ' then&lt;BR /&gt;
        category = 'N';&lt;BR /&gt;
     else if ethnic = ' ' then category = gender;&lt;BR /&gt;
     else if gender = ' ' then category = ethnic;&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
  compute before _type_;&lt;BR /&gt;
    if _type_ = '00' then&lt;BR /&gt;
       brkline = 'Total Population';&lt;BR /&gt;
    else if _type_ = '10' then&lt;BR /&gt;
       brkline = 'Gender';&lt;BR /&gt;
    else if _type_ = '01' then&lt;BR /&gt;
       brkline = 'Ethnicity';&lt;BR /&gt;
    line  brkline $25.;&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
  compute after _type_;&lt;BR /&gt;
    line ' ';&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
  &lt;BR /&gt;
ods html close;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 01 Apr 2008 08:44:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-observations/m-p/7713#M165</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-04-01T08:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: Adding observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-observations/m-p/7714#M166</link>
      <description>You could use dataview\edit mode\insert row, but impractical for datasets with more than 5-6 variables.</description>
      <pubDate>Mon, 23 Jun 2008 16:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-observations/m-p/7714#M166</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-06-23T16:59:31Z</dc:date>
    </item>
  </channel>
</rss>

