<?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 Dataset Structure - Pairs of Observations in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Dataset-Structure-Pairs-of-Observations/m-p/765875#M30589</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following dataset:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input cancer_year cancer_site $10. value_1 value_2 value_3 value_4;
datalines;
1990 breast     100 100 100 100
1990 colorectal 2 1 5 10
1990 lung       8 78 64 30
1990 overall    1 2 3 4
1990 prostate   100 200 300 400
1990 thyroid    0 0 3 4
1991 breast     9 8 7 6
1991 overall    50 60 70 80
1992 overall    10 20 30 40
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I want the following dataset.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want; 
	input cancer_year cancer_site $10. value_1 value_2 value_3 value_4;
datalines;
1990 breast 	100 100 100 100
1990 colorectal 2 1 5 10
1990 lung 		8 78 64 30
1990 overall 	1 2 3 4
1990 prostate 	100 200 300 400
1990 thyroid 	0 0 3 4
1991 breast 	9 8 7 6
1991 colorectal 0 0 0 0
1991 lung 		0 0 0 0
1991 overall 	50 60 70 80
1991 prostate 	0 0 0 0
1991 thyroid 	0 0 0 0
1992 breast 	0 0 0 0
1992 colorectal 0 0 0 0
1992 lung 		0 0 0 0
1992 overall 	10 20 30 40
1992 prostate 	0 0 0 0
1992 thyroid 	0 0 0 0
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What I want is the 6 cancer_site values per each year. And I want zeros for value_1-value_4 for pairs not in the original dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Sep 2021 15:48:54 GMT</pubDate>
    <dc:creator>JJ_83</dc:creator>
    <dc:date>2021-09-03T15:48:54Z</dc:date>
    <item>
      <title>Dataset Structure - Pairs of Observations</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Dataset-Structure-Pairs-of-Observations/m-p/765875#M30589</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following dataset:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input cancer_year cancer_site $10. value_1 value_2 value_3 value_4;
datalines;
1990 breast     100 100 100 100
1990 colorectal 2 1 5 10
1990 lung       8 78 64 30
1990 overall    1 2 3 4
1990 prostate   100 200 300 400
1990 thyroid    0 0 3 4
1991 breast     9 8 7 6
1991 overall    50 60 70 80
1992 overall    10 20 30 40
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I want the following dataset.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want; 
	input cancer_year cancer_site $10. value_1 value_2 value_3 value_4;
datalines;
1990 breast 	100 100 100 100
1990 colorectal 2 1 5 10
1990 lung 		8 78 64 30
1990 overall 	1 2 3 4
1990 prostate 	100 200 300 400
1990 thyroid 	0 0 3 4
1991 breast 	9 8 7 6
1991 colorectal 0 0 0 0
1991 lung 		0 0 0 0
1991 overall 	50 60 70 80
1991 prostate 	0 0 0 0
1991 thyroid 	0 0 0 0
1992 breast 	0 0 0 0
1992 colorectal 0 0 0 0
1992 lung 		0 0 0 0
1992 overall 	10 20 30 40
1992 prostate 	0 0 0 0
1992 thyroid 	0 0 0 0
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What I want is the 6 cancer_site values per each year. And I want zeros for value_1-value_4 for pairs not in the original dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Sep 2021 15:48:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Dataset-Structure-Pairs-of-Observations/m-p/765875#M30589</guid>
      <dc:creator>JJ_83</dc:creator>
      <dc:date>2021-09-03T15:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: Dataset Structure - Pairs of Observations</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Dataset-Structure-Pairs-of-Observations/m-p/765878#M30590</link>
      <description>&lt;P&gt;Here's one way by building a skeleton table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PRELOADFMT works well in PROC TABULATE but will only generate output not a data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CLASSDATA also works but doesn't set the values to 0 automatically.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input cancer_year cancer_site $10. value_1 value_2 value_3 value_4;
datalines;
1990 breast     100 100 100 100
1990 colorectal 2 1 5 10
1990 lung       8 78 64 30
1990 overall    1 2 3 4
1990 prostate   100 200 300 400
1990 thyroid    0 0 3 4
1991 breast     9 8 7 6
1991 overall    50 60 70 80
1992 overall    10 20 30 40
;

proc sql;
create table cancer_sites as
select distinct t1.cancer_site, t2.cancer_year, 0 as value_1, 0 as value_2, 0 as value_3, 0 as value_4
from have as t1, have as t2
order by 2, 1;
quit;

proc sort data=have;
by cancer_year cancer_site;
run;


data want;
update cancer_sites have;
by cancer_year cancer_site;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Sep 2021 16:06:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Dataset-Structure-Pairs-of-Observations/m-p/765878#M30590</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-09-03T16:06:50Z</dc:date>
    </item>
  </channel>
</rss>

