<?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 Missing columns in a new data set in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Missing-columns-in-a-new-data-set/m-p/524803#M4836</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS Studio and I tried to create a new variable using conditional logic. The new variable was created successfully (called NewVar).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My&amp;nbsp;original dataset has 140 columns so I was expecting my data set to have 141 columns (with one new variable). However, my new data set only has 33 columns. Why is that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below are my codes, really appreciate your help! By the way, is there a way to write a statement to keep ALL the variables?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Data_2;&lt;BR /&gt;Set WORK.PRINTSORTEDDATA;&lt;BR /&gt;Length NewVar 4;&lt;BR /&gt;IF B6 = 1 THEN &lt;SPAN&gt;NewVar &lt;/SPAN&gt;= 6;&lt;BR /&gt;ELSE IF B7 = 1 then &lt;SPAN&gt;NewVar &lt;/SPAN&gt;= 5;&lt;BR /&gt;else if B7 = 2 then &lt;SPAN&gt;NewVar &lt;/SPAN&gt;= 4;&lt;BR /&gt;else if B7 = 3 then &lt;SPAN&gt;NewVar &lt;/SPAN&gt;= 3;&lt;BR /&gt;else if B7 = 4 then &lt;SPAN&gt;NewVar &lt;/SPAN&gt;= 2;&lt;BR /&gt;else if B7 = 5 then &lt;SPAN&gt;NewVar &lt;/SPAN&gt;= 1;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 05 Jan 2019 13:08:18 GMT</pubDate>
    <dc:creator>butterfly_wing</dc:creator>
    <dc:date>2019-01-05T13:08:18Z</dc:date>
    <item>
      <title>Missing columns in a new data set</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Missing-columns-in-a-new-data-set/m-p/524803#M4836</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS Studio and I tried to create a new variable using conditional logic. The new variable was created successfully (called NewVar).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My&amp;nbsp;original dataset has 140 columns so I was expecting my data set to have 141 columns (with one new variable). However, my new data set only has 33 columns. Why is that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below are my codes, really appreciate your help! By the way, is there a way to write a statement to keep ALL the variables?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Data_2;&lt;BR /&gt;Set WORK.PRINTSORTEDDATA;&lt;BR /&gt;Length NewVar 4;&lt;BR /&gt;IF B6 = 1 THEN &lt;SPAN&gt;NewVar &lt;/SPAN&gt;= 6;&lt;BR /&gt;ELSE IF B7 = 1 then &lt;SPAN&gt;NewVar &lt;/SPAN&gt;= 5;&lt;BR /&gt;else if B7 = 2 then &lt;SPAN&gt;NewVar &lt;/SPAN&gt;= 4;&lt;BR /&gt;else if B7 = 3 then &lt;SPAN&gt;NewVar &lt;/SPAN&gt;= 3;&lt;BR /&gt;else if B7 = 4 then &lt;SPAN&gt;NewVar &lt;/SPAN&gt;= 2;&lt;BR /&gt;else if B7 = 5 then &lt;SPAN&gt;NewVar &lt;/SPAN&gt;= 1;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Jan 2019 13:08:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Missing-columns-in-a-new-data-set/m-p/524803#M4836</guid>
      <dc:creator>butterfly_wing</dc:creator>
      <dc:date>2019-01-05T13:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: Missing columns in a new data set</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Missing-columns-in-a-new-data-set/m-p/524811#M4837</link>
      <description>&lt;P&gt;Nothing in your code will decrease columns. use proc contents to see columns of both the tables, that will give you good idea on what is happening.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc contents data = Data_2;
run;

Proc contents data = PRINTSORTEDDATA;
run;

/* You can use dictionay.columns to find what are columns which are not there. example code below and you can use the same for your code*/

data class;
		set sashelp.class(drop=age);
		run;

proc sql ;
 select coalesce(a.name, b.name) as missing_column
 from 
	   (select name from Dictionary.columns
	     where upcase(libname)=upcase('work') and 
	     upcase(memname)=upcase('class'))a 
full join
      (Select name from Dictionary.columns
       where upcase(libname)=upcase('SASHELP') and 
		upcase(memname)=upcase('CLASS'))b 
		
on upcase(a.name)=upcase(b.name) 
 where a.name is missing or b.name is missing;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 05 Jan 2019 14:01:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Missing-columns-in-a-new-data-set/m-p/524811#M4837</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2019-01-05T14:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: Missing columns in a new data set</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Missing-columns-in-a-new-data-set/m-p/524829#M4845</link>
      <description>&lt;P&gt;Check your log? You likely have an error somewhere and are working with a partial data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/252927"&gt;@butterfly_wing&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using SAS Studio and I tried to create a new variable using conditional logic. The new variable was created successfully (called NewVar).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My&amp;nbsp;original dataset has 140 columns so I was expecting my data set to have 141 columns (with one new variable). However, my new data set only has 33 columns. Why is that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below are my codes, really appreciate your help! By the way, is there a way to write a statement to keep ALL the variables?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data Data_2;&lt;BR /&gt;Set WORK.PRINTSORTEDDATA;&lt;BR /&gt;Length NewVar 4;&lt;BR /&gt;IF B6 = 1 THEN &lt;SPAN&gt;NewVar &lt;/SPAN&gt;= 6;&lt;BR /&gt;ELSE IF B7 = 1 then &lt;SPAN&gt;NewVar &lt;/SPAN&gt;= 5;&lt;BR /&gt;else if B7 = 2 then &lt;SPAN&gt;NewVar &lt;/SPAN&gt;= 4;&lt;BR /&gt;else if B7 = 3 then &lt;SPAN&gt;NewVar &lt;/SPAN&gt;= 3;&lt;BR /&gt;else if B7 = 4 then &lt;SPAN&gt;NewVar &lt;/SPAN&gt;= 2;&lt;BR /&gt;else if B7 = 5 then &lt;SPAN&gt;NewVar &lt;/SPAN&gt;= 1;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Jan 2019 19:00:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Missing-columns-in-a-new-data-set/m-p/524829#M4845</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-05T19:00:50Z</dc:date>
    </item>
  </channel>
</rss>

