<?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 how to create a new variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/how-to-create-a-new-variable/m-p/617143#M19019</link>
    <description>&lt;P&gt;I have a datset of Comcast Telecom Consumer Complaints .I need help . To create a new variable in my existing dataset in new&amp;nbsp;column.&lt;/P&gt;&lt;P&gt;. i am poviding a screenshot&amp;nbsp; of my dataset&amp;nbsp; &amp;nbsp;in photos&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Data Dictionary&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Ticket #: Ticket number assigned to each complaint&lt;/LI&gt;&lt;LI&gt;Customer Complaint: Description of complaint&lt;/LI&gt;&lt;LI&gt;Date: Date of complaint&lt;/LI&gt;&lt;LI&gt;Time: Time of complaint&lt;/LI&gt;&lt;LI&gt;Received Via: Mode of communication of the complaint&lt;/LI&gt;&lt;LI&gt;City: Customer city&lt;/LI&gt;&lt;LI&gt;State: Customer state&lt;/LI&gt;&lt;LI&gt;Zipcode: Customer zip&lt;/LI&gt;&lt;LI&gt;Status: Status of complaint&lt;/LI&gt;&lt;LI&gt;Filing on behalf of someone&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;U&gt;Analysis Task&lt;/U&gt;&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Create a new categorical variable with value as&amp;nbsp;&lt;STRONG&gt;Open&amp;nbsp;&lt;/STRONG&gt;and&amp;nbsp;&lt;STRONG&gt;Closed&lt;/STRONG&gt;. Open &amp;amp;&amp;nbsp;Pending is to be categorized as Open and Closed &amp;amp;&amp;nbsp;Solved is to be categorized as Closed&lt;/P&gt;&lt;P&gt;i tried many ways but&amp;nbsp; unable to create new variable&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1)
data mylib.concast4;
set mylib.concast;
if Status in('Open','Pending') then new_status='Open';
else Status in('Closed ','Solved' ) then new_status='Closed';
run;
error is 
 error: statement is not valid or out of  proper order.
2)
proc sql;
create table mylib.concast4 as
select * from  mylib.concast
case
when status in ('open' ,'pending') then new_status='open'
when status in ('closed','solved') then new_status='closed'
else 'others'
end as new_status
from  mylib.concast;
quit;

error is ;
ERROR 22-322: Syntax error, expecting one of the following: ;, ',', ANSIMISS, CROSS, EXCEPT, FULL, GROUP, HAVING, INNER, INTERSECT, 
               JOIN, LEFT, NATURAL, NOMISS, ORDER, OUTER, RIGHT, UNION, WHERE.  
 
 ERROR 76-322: Syntax error, statement will be ignored
 
 &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="sample datset.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35322iE2F4A8C69D7333A7/image-size/large?v=v2&amp;amp;px=999" role="button" title="sample datset.PNG" alt="sample datset.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;please help me.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Jan 2020 07:11:56 GMT</pubDate>
    <dc:creator>manjuhiten28</dc:creator>
    <dc:date>2020-01-14T07:11:56Z</dc:date>
    <item>
      <title>how to create a new variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-create-a-new-variable/m-p/617143#M19019</link>
      <description>&lt;P&gt;I have a datset of Comcast Telecom Consumer Complaints .I need help . To create a new variable in my existing dataset in new&amp;nbsp;column.&lt;/P&gt;&lt;P&gt;. i am poviding a screenshot&amp;nbsp; of my dataset&amp;nbsp; &amp;nbsp;in photos&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Data Dictionary&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Ticket #: Ticket number assigned to each complaint&lt;/LI&gt;&lt;LI&gt;Customer Complaint: Description of complaint&lt;/LI&gt;&lt;LI&gt;Date: Date of complaint&lt;/LI&gt;&lt;LI&gt;Time: Time of complaint&lt;/LI&gt;&lt;LI&gt;Received Via: Mode of communication of the complaint&lt;/LI&gt;&lt;LI&gt;City: Customer city&lt;/LI&gt;&lt;LI&gt;State: Customer state&lt;/LI&gt;&lt;LI&gt;Zipcode: Customer zip&lt;/LI&gt;&lt;LI&gt;Status: Status of complaint&lt;/LI&gt;&lt;LI&gt;Filing on behalf of someone&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;&lt;U&gt;Analysis Task&lt;/U&gt;&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Create a new categorical variable with value as&amp;nbsp;&lt;STRONG&gt;Open&amp;nbsp;&lt;/STRONG&gt;and&amp;nbsp;&lt;STRONG&gt;Closed&lt;/STRONG&gt;. Open &amp;amp;&amp;nbsp;Pending is to be categorized as Open and Closed &amp;amp;&amp;nbsp;Solved is to be categorized as Closed&lt;/P&gt;&lt;P&gt;i tried many ways but&amp;nbsp; unable to create new variable&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1)
data mylib.concast4;
set mylib.concast;
if Status in('Open','Pending') then new_status='Open';
else Status in('Closed ','Solved' ) then new_status='Closed';
run;
error is 
 error: statement is not valid or out of  proper order.
2)
proc sql;
create table mylib.concast4 as
select * from  mylib.concast
case
when status in ('open' ,'pending') then new_status='open'
when status in ('closed','solved') then new_status='closed'
else 'others'
end as new_status
from  mylib.concast;
quit;

error is ;
ERROR 22-322: Syntax error, expecting one of the following: ;, ',', ANSIMISS, CROSS, EXCEPT, FULL, GROUP, HAVING, INNER, INTERSECT, 
               JOIN, LEFT, NATURAL, NOMISS, ORDER, OUTER, RIGHT, UNION, WHERE.  
 
 ERROR 76-322: Syntax error, statement will be ignored
 
 &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="sample datset.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35322iE2F4A8C69D7333A7/image-size/large?v=v2&amp;amp;px=999" role="button" title="sample datset.PNG" alt="sample datset.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;please help me.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2020 07:11:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-create-a-new-variable/m-p/617143#M19019</guid>
      <dc:creator>manjuhiten28</dc:creator>
      <dc:date>2020-01-14T07:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a new variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-create-a-new-variable/m-p/617146#M19020</link>
      <description>&lt;P&gt;Please post the complete log as text.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2020 07:26:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-create-a-new-variable/m-p/617146#M19020</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-01-14T07:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a new variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-create-a-new-variable/m-p/617147#M19021</link>
      <description>&lt;P&gt;0) DO NOT post data in pictures, use a data step with datalines so we can easily recreate your dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) a "then" always needs an "if":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mylib.concast4;
set mylib.concast;
if Status in('Open','Pending') then new_status='Open';
else if Status in('Closed ','Solved' ) then new_status='Closed';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2) why do you have two "from" clauses in your SQL select? Only one is needed, and it has to come AFTER the column list:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table mylib.concast4 as
select
  *, 
  case
    when status in ('open' ,'pending') then new_status='open'
    when status in ('closed','solved') then new_status='closed'
    else 'others'
  end as new_status
from  mylib.concast;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Make sure that your literals match the contents of status in terms of spelling and capitalization.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2020 07:28:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-create-a-new-variable/m-p/617147#M19021</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-01-14T07:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a new variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-create-a-new-variable/m-p/641515#M21830</link>
      <description>Can you please share complete solution for this to me, Thank you for your kind help in advance.</description>
      <pubDate>Tue, 21 Apr 2020 03:33:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-create-a-new-variable/m-p/641515#M21830</guid>
      <dc:creator>Gupta</dc:creator>
      <dc:date>2020-04-21T03:33:24Z</dc:date>
    </item>
  </channel>
</rss>

