<?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 new variable but everything goes missing? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81421#M23474</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your time and reply.&lt;/P&gt;&lt;P&gt;I am not working on this.This was posted originally by another person. I am learning SAS and techniques involved....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Mar 2013 18:18:37 GMT</pubDate>
    <dc:creator>robertrao</dc:creator>
    <dc:date>2013-03-20T18:18:37Z</dc:date>
    <item>
      <title>Creating new variable but everything goes missing?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81404#M23457</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi. I'm trying to create a new variable. I have variable 'labor' where less than 37 weeks is premature, and anything 37 and above is normal. I want to create a new variable called 'delivery' where 1=premature and 2=normal, then figure out how many premature and normal deliveries there are. Below is the code I'm using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data hosp_data;&lt;/P&gt;&lt;P&gt;if labor &amp;lt; 37 then delivery=1;&lt;/P&gt;&lt;P&gt;else if labor &amp;gt;= 37 then delivery=2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And here's what the log tells me: &lt;/P&gt;&lt;P&gt;NOTE: Variable labor is uninitialized.&lt;/P&gt;&lt;P&gt;NOTE: The data set HOSP_DATA has 1 observations and 2 variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The output shows 1 missing observation. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What am I doing wrong??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Mar 2013 13:59:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81404#M23457</guid>
      <dc:creator>SASstudent2013</dc:creator>
      <dc:date>2013-03-19T13:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable but everything goes missing?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81405#M23458</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First, you need to &lt;STRONG&gt;SET &lt;/STRONG&gt;your data set...like,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data hosp_data;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;set data_you_have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Then, I would (just out of habit) make sure to exclude the missing values when you create delivery = 1:&lt;/P&gt;&lt;P&gt;if &lt;STRONG&gt;. &amp;lt;&lt;/STRONG&gt; labor &amp;lt; 37 then delivery=1;&lt;/P&gt;&lt;P&gt;else if labor &amp;gt;= 37 then delivery=2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, it would be 'cleaner' to just create an indicator for delivery premature yes/no:&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value yesno 1 = "Premaure" 0 = "Not premature";quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data hosp_data;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;set data_you_have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;delivery_premature = (. &amp;lt; labor &amp;lt; 37);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format delivery_premature yesno.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Mar 2013 14:09:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81405#M23458</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2013-03-19T14:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable but everything goes missing?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81406#M23459</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. When I try it the first way, I get an error message saying the set statement doesn't exist...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;data hosp_data;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set data_case2;&lt;/P&gt;&lt;P&gt;if . &amp;lt; labor &amp;lt; 37 then delivery=1;&lt;/P&gt;&lt;P&gt;else if labor &amp;gt;= 37 then delivery=2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOG ERROR: ERROR: File WORK.DATA_CASE2.DATA does not exist.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you know why I'm getting that error?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Mar 2013 14:29:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81406#M23459</guid>
      <dc:creator>SASstudent2013</dc:creator>
      <dc:date>2013-03-19T14:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable but everything goes missing?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81407#M23460</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you have the data set named:l &lt;STRONG&gt;data_case2&lt;/STRONG&gt; in your WORK library, or is it a permanent file somewhere else??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Mar 2013 14:33:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81407#M23460</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2013-03-19T14:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable but everything goes missing?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81408#M23461</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is how I start my code (and I get an error with the libname statement):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname data1;&lt;/P&gt;&lt;P&gt;proc import datafile="...hosp.xls"&lt;/P&gt;&lt;P&gt;out=hosp_data1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR: data1 is not a valid SAS name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So not sure if that will help?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Mar 2013 16:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81408#M23461</guid>
      <dc:creator>SASstudent2013</dc:creator>
      <dc:date>2013-03-19T16:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable but everything goes missing?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81409#M23462</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So you have errors from the beginning? Then your errors will carry through. You may want to review this website&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.ats.ucla.edu/stat/sas/notes/default.htm" title="http://www.ats.ucla.edu/stat/sas/notes/default.htm"&gt;SAS Class Notes&lt;/A&gt; to learn more about SAS. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Additionally, start debugging your code line by line or proc by proc from the top. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Mar 2013 16:38:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81409#M23462</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-03-19T16:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable but everything goes missing?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81410#M23463</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;so, libname data1.... is missing a path&lt;/P&gt;&lt;P&gt;the reason you create a libname is to either retrieve or store a &lt;STRONG&gt;permanent&amp;nbsp; &lt;/STRONG&gt;data set.&lt;/P&gt;&lt;P&gt;libname data1 "&lt;STRONG&gt;give a path name such as C:\Documents and Settings\User"&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;proc import datafile="...hosp.xls"&lt;/P&gt;&lt;P&gt;out=hosp_data1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ok, give us more code so we can figure out where things break....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Mar 2013 18:07:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81410#M23463</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2013-03-19T18:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable but everything goes missing?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81411#M23464</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data hosp_data;&lt;/P&gt;&lt;P&gt;set data_you_have;&lt;/P&gt;&lt;P&gt;delivery_premature = (. &amp;lt; labor &amp;lt; 37);&amp;nbsp;&amp;nbsp;&amp;nbsp; /*what does this step do??creating a new variable called delivery_premature and what does (. &amp;lt; labor &amp;lt; 37) do;&lt;/P&gt;&lt;P&gt;format delivery_premature yesno.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&lt;BR /&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 14:33:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81411#M23464</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-03-20T14:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable but everything goes missing?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81412#M23465</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;This line&lt;/P&gt;&lt;P&gt;delivery_premature = (. &amp;lt; labor &amp;lt; 37);&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;is similar to&lt;/P&gt;&lt;P&gt;if (. &amp;lt; delivery &amp;lt; 37) then delivery_premature = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else delivery_premature = 2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IT is basically a short way to create a dummy variable (0/1).for a given condition.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 14:44:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81412#M23465</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2013-03-20T14:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable but everything goes missing?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81413#M23466</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could you please explain with a small example??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 15:10:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81413#M23466</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-03-20T15:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable but everything goes missing?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81414#M23467</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;This line&lt;/P&gt;&lt;P&gt;delivery_premature = (. &amp;lt; labor &amp;lt; 37);&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;is similar to&lt;/P&gt;&lt;P&gt;if (. &amp;lt; delivery &amp;lt; 37) then delivery_premature = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else delivery_premature = 2;&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;&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;&amp;nbsp;&amp;nbsp; /*should have been 0 instead of 2 here????????*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IT is basically a short way to create a dummy variable (0/1).for a given condition.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 15:56:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81414#M23467</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-03-20T15:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable but everything goes missing?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81415#M23468</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi I tried this example and it does not work..Could you please explain&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input labor;&lt;BR /&gt;cards;&lt;BR /&gt;35&lt;BR /&gt;43&lt;BR /&gt;30&lt;BR /&gt;33&lt;BR /&gt;22&lt;BR /&gt;20&lt;BR /&gt;15&lt;BR /&gt;19&lt;BR /&gt;37&lt;BR /&gt;36&lt;BR /&gt;38&lt;BR /&gt;39&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have1;&lt;BR /&gt;set have;&lt;BR /&gt;if . &amp;lt; labor &amp;lt; 37 then delivery=1;&lt;/P&gt;&lt;P&gt;else if labor &amp;gt;= 37 then delivery=2;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format;&lt;BR /&gt;value yesno 1 = "Premaure" &lt;BR /&gt;0 = "Not premature";&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have2;&lt;BR /&gt;set have1;&lt;BR /&gt;if (. &amp;lt; delivery &amp;lt; 37) then delivery_premature = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else delivery_premature = 2;&lt;BR /&gt;format delivery_premature yesno.;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 16:28:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81415#M23468</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-03-20T16:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable but everything goes missing?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81416#M23469</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You set delivery to only 1 or 2 in the first step (have1) but then are checking if its between . and 37 in the second step. delivery_premature will always be 1 won't it?&lt;/P&gt;&lt;P&gt;I think your looking for the following.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input labor;&lt;BR /&gt;cards;&lt;BR /&gt;35&lt;BR /&gt;43&lt;BR /&gt;30&lt;BR /&gt;33&lt;BR /&gt;22&lt;BR /&gt;20&lt;BR /&gt;15&lt;BR /&gt;19&lt;BR /&gt;37&lt;BR /&gt;36&lt;BR /&gt;38&lt;BR /&gt;39&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;value yesno 1 = "Premature" &lt;/P&gt;&lt;P&gt;0 = "Not premature";&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have1;&lt;BR /&gt;set have;&lt;BR /&gt;if . &amp;lt; labor &amp;lt; 37 then delivery=1;&lt;/P&gt;&lt;P&gt;else if labor &amp;gt;= 37 then delivery=2;&lt;/P&gt;&lt;P&gt;format delivery yesno.;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 16:34:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81416#M23469</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-03-20T16:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable but everything goes missing?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81417#M23470</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, i understood it better now&lt;/P&gt;&lt;P&gt;and since the format has 0 and 1 only. So should it not be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have1;&lt;BR /&gt;set have;&lt;BR /&gt;if . &amp;lt; labor &amp;lt; 37 then delivery=1;&lt;/P&gt;&lt;P&gt;else if labor &amp;gt;= 37 then delivery=&lt;STRONG&gt;2&lt;/STRONG&gt;;&amp;nbsp; /*should it not be 0 here*/&lt;/P&gt;&lt;P&gt;format delivery yesno.;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 16:45:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81417#M23470</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-03-20T16:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable but everything goes missing?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81418#M23471</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't understand the confusion, Robert.&lt;/P&gt;&lt;P&gt;You want to be able to tell when a delivery is strictly less than 37 months, and when it is greater than 37 (inclusive) months.&lt;/P&gt;&lt;P&gt;So, based on the data set have that you used in the above reply, you get exactly that when you run this code:&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;value yesno 1 = "Premature"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;0 = "Not premature";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have2;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;delivery_premature = (. &amp;lt; labor &amp;lt; 37);&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;format delivery_premature yesno.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know what happens when you run this above code??&lt;/P&gt;&lt;P&gt;when you use delivery_premature = (. &amp;lt; delivery &amp;lt; 37) ....what this translates to is:&lt;/P&gt;&lt;P&gt;SAS please put a 1 whenever this condition (. &amp;lt; delivery &amp;lt; 37) is true, and put a 0 otherwise, which should save you from writing the next line (else if delivery &amp;gt;= 37)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 17:46:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81418#M23471</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2013-03-20T17:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable but everything goes missing?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81419#M23472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sorry about that..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code which you posted works exactly fine...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Secondly, I was trying to run it by replacing&lt;/P&gt;&lt;P&gt;delivery_premature = (. &amp;lt; labor &amp;lt; 37);&amp;nbsp; with what you explained.......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (. &amp;lt; delivery &amp;lt; 37) then delivery_premature = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else delivery_premature = &lt;STRONG&gt;2&lt;/STRONG&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*did u put this 2 here by mistake........i think it should be 0 because the format has only 1 and 0 and no 2*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please correct me&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 17:53:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81419#M23472</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-03-20T17:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable but everything goes missing?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81420#M23473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you are correct it should be 0 (to allow for my format definition to work), or if you prefer to be 2, then you change&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;value yesno 1 = "Premature" 2 = "Not premature"&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Either 2 or 0, whatever you prefer.&lt;/P&gt;&lt;P&gt;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, do you have your data set working?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 18:14:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81420#M23473</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2013-03-20T18:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable but everything goes missing?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81421#M23474</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your time and reply.&lt;/P&gt;&lt;P&gt;I am not working on this.This was posted originally by another person. I am learning SAS and techniques involved....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 18:18:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81421#M23474</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-03-20T18:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable but everything goes missing?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81422#M23475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Right &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;:smileylaugh:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ok, good day!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 18:20:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81422#M23475</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2013-03-20T18:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating new variable but everything goes missing?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81423#M23476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;Also shouldnt the highlighted "DELIVERY " be replaced by LABOR&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Secondly, I was trying to run it by replacing&lt;/P&gt;&lt;P&gt;delivery_premature = (. &amp;lt; labor &amp;lt; 37);&amp;nbsp; with what you explained.......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (. &amp;lt; &lt;STRONG&gt;delivery&lt;/STRONG&gt; &amp;lt; 37) then delivery_premature = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else delivery_premature = &lt;STRONG&gt;2&lt;/STRONG&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*did u put this 2 here by mistake........i think it should be 0 because the format has only 1 and 0 and no 2*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please correct me&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2013 18:41:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-new-variable-but-everything-goes-missing/m-p/81423#M23476</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2013-03-20T18:41:18Z</dc:date>
    </item>
  </channel>
</rss>

