<?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: SAS error during datastep in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-error-during-datastep/m-p/270111#M53620</link>
    <description>&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;</description>
    <pubDate>Thu, 12 May 2016 17:39:36 GMT</pubDate>
    <dc:creator>nohassles</dc:creator>
    <dc:date>2016-05-12T17:39:36Z</dc:date>
    <item>
      <title>SAS error during datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-error-during-datastep/m-p/270099#M53614</link>
      <description>&lt;P&gt;SAS Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to&amp;nbsp;distribute records from a statewide dataset into&amp;nbsp;smaller datasets that represent regions in the state.&amp;nbsp;The variable I am looking at is pfi and using the IN operator, I am&amp;nbsp;seeking to&amp;nbsp;match&amp;nbsp;values to output observations into the regialonal datasets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am gtting a SAS&amp;nbsp;error about a dataset already being open for output.&amp;nbsp;I don't see the coding&amp;nbsp;error or know of a limitiation that&amp;nbsp;would trigger the error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;99 option mrecall mautosource noimplmac;&lt;/P&gt;&lt;P&gt;100 /* Change libname path to local work folder */&lt;/P&gt;&lt;P&gt;101&lt;/P&gt;&lt;P&gt;102 LIBNAME obs 'D:\Data\SPARCS\DiagProc\Work';&lt;/P&gt;&lt;P&gt;NOTE: Libref OBS was successfully assigned as follows:&lt;/P&gt;&lt;P&gt;Engine: V9&lt;/P&gt;&lt;P&gt;Physical Name: D:\Data\SPARCS\DiagProc\Work&lt;/P&gt;&lt;P&gt;103 %global sqlyr1;&lt;/P&gt;&lt;P&gt;104 %global longdate;&lt;/P&gt;&lt;P&gt;105 %LET sqlyr1=2014; *4 digit year being EVALUATED (no quotes);&lt;/P&gt;&lt;P&gt;106 %LET longdate=April 1, 2016;&lt;/P&gt;&lt;P&gt;107&lt;/P&gt;&lt;P&gt;108 %macro year2;&lt;/P&gt;&lt;P&gt;109 %global sqlyr2;&lt;/P&gt;&lt;P&gt;110 %let sqlyr2=%eval(&amp;amp;sqlyr1+1);&lt;/P&gt;&lt;P&gt;111 %mend year2;&lt;/P&gt;&lt;P&gt;112&lt;/P&gt;&lt;P&gt;113 %year2;&lt;/P&gt;&lt;P&gt;114 DATA obs.wny_ip_dx_pr_w_avg&lt;/P&gt;&lt;P&gt;115 obs.fl_ip_dx_pr_w_avg&lt;/P&gt;&lt;P&gt;116 obs.cny_ip_dx_pr_w_avg&lt;/P&gt;&lt;P&gt;117 obs.ne_ip_dx_pr_w_avg&lt;/P&gt;&lt;P&gt;118 obs.hv_ip_dx_pr_w_avg&lt;/P&gt;&lt;P&gt;119 obs.ne_ip_dx_pr_w_avg&lt;/P&gt;&lt;P&gt;120 obs.nyc_ip_dx_pr_w_avg&lt;/P&gt;&lt;P&gt;121 obs.li_ip_dx_pr_w_avg&lt;/P&gt;&lt;P&gt;122 obs.unknown;&lt;/P&gt;&lt;P&gt;123&lt;/P&gt;&lt;P&gt;124 SET obs.final_ip_dx_pr_w_avg;&lt;/P&gt;&lt;P&gt;125&lt;/P&gt;&lt;P&gt;126 IF pfi IN ('000037','000039','000066','000098','000102','000103','000111','000114','000207','000213',&lt;/P&gt;&lt;P&gt;127 '000216','000218','000267','000280','000292','000339','000340','000565','000574','000581',&lt;/P&gt;&lt;P&gt;128 '000583','000718','001153','003067')&lt;/P&gt;&lt;P&gt;129 THEN OUTPUT obs.wny_ip_dx_pr_w_avg;&lt;/P&gt;&lt;P&gt;130 ELSE IF pfi IN ('000116','000118','000393','000409','000411','000412','000413','000414','000471','000671',&lt;/P&gt;&lt;P&gt;131 '000676','000678','000858','000866','000870','000873','001028','001158','005785')&lt;/P&gt;&lt;P&gt;132 THEN OUTPUT obs.fl_ip_dx_pr_w_avg;&lt;/P&gt;&lt;P&gt;133 ELSE IF pfi IN ('000012','000085','000158','000362','000367','000377','000379','000383','000397','000401',&lt;/P&gt;&lt;P&gt;134 '000589','000598','000599','000628','000630','000635','000636','000727','000798','000804',&lt;/P&gt;&lt;P&gt;135 '000812','000815','000817','000977','009059','000042','000043','000058','000128')&lt;/P&gt;&lt;P&gt;136 THEN OUTPUT obs.cny_ip_dx_pr_w_avg;&lt;/P&gt;&lt;P&gt;137 ELSE IF pfi IN ('000001','000002','000004','000005','000135','000146','000165','000170','000174','000303',&lt;/P&gt;&lt;P&gt;138 '000309','000324','000325','000330','000482','000484','000739','000746','000755','000756',&lt;/P&gt;&lt;P&gt;139 '000818','000829','000831','000848','000851','001005','008554','009250','009431')&lt;/P&gt;&lt;P&gt;140 THEN OUTPUT obs.ne_ip_dx_pr_w_avg;&lt;/P&gt;&lt;P&gt;141 ELSE IF pfi IN ('000180','000181','000192','000694','000699','000704','000708','000752','000775','000776',&lt;/P&gt;&lt;P&gt;142 '000779','000968','000971','000989','000990','001002','001039','001045','001046','001047',&lt;/P&gt;&lt;P&gt;143 '001061','001072','001097','001098','001099','001117','001122','001124','001129','001133',&lt;/P&gt;&lt;P&gt;144 '001138','001139')&lt;/P&gt;&lt;P&gt;145 THEN OUTPUT obs.hv_ip_dx_pr_w_avg;&lt;/P&gt;&lt;P&gt;146 ELSE IF pfi IN ('001164','001165','001168','001169','001172','001175','001176','001178','001186','001286',&lt;/P&gt;&lt;P&gt;147 '001288','001293','001294','001301','001304','001305','001306','001309','001315','001318',&lt;/P&gt;&lt;P&gt;148 '001320','001324','001437','001438','001439','001445','001446','001447','001450','001453',&lt;/P&gt;&lt;P&gt;149 '001454','001456','001458','001460','001463','001464','001465','001466','001469','001473',&lt;/P&gt;&lt;P&gt;150 '001486','001487','001626','001628','001629','001630','001633','001635','001637','001638',&lt;/P&gt;&lt;P&gt;151 '001639','001692','001737','001738','001740','003058','003376','003975','009700')&lt;/P&gt;&lt;P&gt;152 THEN OUTPUT obs.nyc_ip_dx_pr_w_avg;&lt;/P&gt;&lt;P&gt;153 ELSE IF pfi IN ('000245','000490','000511','000513','000518','000527','000528','000541','000550','000551',&lt;/P&gt;&lt;P&gt;154 '000552','000563','000885','000889','000891','000895','000896','000913','000924','000925',&lt;/P&gt;&lt;P&gt;155 '000938','000943') THEN OUTPUT obs.li_ip_dx_pr_w_avg;&lt;/P&gt;&lt;P&gt;156 ELSE OUTPUT obs.unknown;&lt;/P&gt;&lt;P&gt;157 RUN;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;ERROR: Data set OBS.NE_IP_DX_PR_W_AVG is already open for output.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;&lt;P&gt;WARNING: The data set OBS.WNY_IP_DX_PR_W_AVG may be incomplete. When this step was stopped there were 0 observations and 23 variables.&lt;/P&gt;&lt;P&gt;WARNING: The data set OBS.FL_IP_DX_PR_W_AVG may be incomplete. When this step was stopped there were 0 observations and 23 variables.&lt;/P&gt;&lt;P&gt;WARNING: The data set OBS.CNY_IP_DX_PR_W_AVG may be incomplete. When this step was stopped there were 0 observations and 23 variables.&lt;/P&gt;&lt;P&gt;WARNING: The data set OBS.NE_IP_DX_PR_W_AVG may be incomplete. When this step was stopped there were 0 observations and 23 variables.&lt;/P&gt;&lt;P&gt;WARNING: The data set OBS.HV_IP_DX_PR_W_AVG may be incomplete. When this step was stopped there were 0 observations and 23 variables.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;real time 0.03 seconds&lt;/P&gt;&lt;P&gt;cpu time 0.03 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 16:35:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-error-during-datastep/m-p/270099#M53614</guid>
      <dc:creator>nohassles</dc:creator>
      <dc:date>2016-05-12T16:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: SAS error during datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-error-during-datastep/m-p/270106#M53617</link>
      <description>&lt;P&gt;It looks like you mention this data set name twice on the DATA statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;obs.ne_ip_dx_pr_w_avg&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try removing one instance of that name.&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 17:35:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-error-during-datastep/m-p/270106#M53617</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-05-12T17:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: SAS error during datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-error-during-datastep/m-p/270107#M53618</link>
      <description>&lt;P&gt;That means you have the data set open in viewer, or someone does.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To overwrite a dataset it must be closed. If you can't find it, try deleting the dataset manually and then overwriting it.&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 17:36:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-error-during-datastep/m-p/270107#M53618</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-12T17:36:32Z</dc:date>
    </item>
    <item>
      <title>Re: SAS error during datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-error-during-datastep/m-p/270110#M53619</link>
      <description>&lt;P&gt;Thank you. That is the power of a second set of eyes looking at the code!&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 17:38:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-error-during-datastep/m-p/270110#M53619</guid>
      <dc:creator>nohassles</dc:creator>
      <dc:date>2016-05-12T17:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: SAS error during datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-error-during-datastep/m-p/270111#M53620</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 17:39:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-error-during-datastep/m-p/270111#M53620</guid>
      <dc:creator>nohassles</dc:creator>
      <dc:date>2016-05-12T17:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: SAS error during datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-error-during-datastep/m-p/270237#M53661</link>
      <description>&lt;P&gt;If I were working with similar data with any frequency (and I do) I would create custom formats, put them in a permanent library&amp;nbsp;and make sure that the FMTSEARCH path was set to include that library as it can simply &lt;STRONG&gt;many&lt;/STRONG&gt; tasks. A brief example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format library=work;
value $PF1Code
'000037','000039','000066','000098','000102','000​103','000111','000114','000207','000213',
'000216','000218','000267','000280','000292','0003​39','000340','000565','000574','000581',
'000583','000718','001153','003067'
= "WNY"
'000116','000118','000393','000409','000411','000​412','000413','000414','000471','000671',
'000676','000678','000858','000866','000870','0008​73','001028','001158','005785'
= "FL"
'000012','000085','000158','000362','000367','000​377','000379','000383','000397','000401',
'000589','000598','000599','000628','000630','0006​35','000636','000727','000798','000804',
'000812','000815','000817','000977','009059','0000​42','000043','000058','000128'
= "CNY"
'000001','000002','000004','000005','000135','000​146','000165','000170','000174','000303',
'000309','000324','000325','000330','000482','0004​84','000739','000746','000755','000756',
'000818','000829','000831','000848','000851','0010​05','008554','009250','009431'
= "NE"
'000180','000181','000192','000694','000699','000​704','000708','000752','000775','000776',
'000779','000968','000971','000989','000990','0010​02','001039','001045','001046','001047',
'001061','001072','001097','001098','001099','0011​17','001122','001124','001129','001133',
'001138','001139'
= "HV"
'001164','001165','001168','001169','001172','001​175','001176','001178','001186','001286',
'001288','001293','001294','001301','001304','0013​05','001306','001309','001315','001318',
'001320','001324','001437','001438','001439','0014​45','001446','001447','001450','001453',
'001454','001456','001458','001460','001463','0014​64','001465','001466','001469','001473',
'001486','001487','001626','001628','001629','0016​30','001633','001635','001637','001638',
'001639','001692','001737','001738','001740','0030​58','003376','003975','009700'
= "NYC"
'000245','000490','000511','000513','000518','000​527','000528','000541','000550','000551',
'000552','000563','000885','000889','000891','0008​95','000896','000913','000924','000925',
'000938','000943' = "LI"
;
Run;

Data example;
   input PF1 $;
datalines;
000037
000216
000583
000116
000676
000012
000589
000812
000001
000309
000818
000180
000779
001061
001138
001164
001288
001320
001454
001486
001639
000245
000552
000938
;
run;

proc freq data=example;
   tables Pf1;
   Format Pf1 $Pf1Code.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You multiple IF statements with that format could be reduced to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA 
   obs.wny_ip_dx_pr_w_avg
   obs.fl_ip_dx_pr_w_avg
   obs.cny_ip_dx_pr_w_avg
   obs.ne_ip_dx_pr_w_avg
   obs.hv_ip_dx_pr_w_avg
   obs.nyc_ip_dx_pr_w_avg
   obs.li_ip_dx_pr_w_avg
   obs.unknown
;
   SET obs.final_ip_dx_pr_w_avg;
   select (Put(Pf1,$PF1code.));
      when ('WNY') output obs.wny_ip_dx_pr_w_avg;
      when ('FL')  output obs.fl_ip_dx_pr_w_avg;
      when ('CNY') output obs.cny_ip_dx_pr_w_avg;
      when ('NE')  output obs.ne_ip_dx_pr_w_avg;
      when ('HV')  output obs.hv_ip_dx_pr_w_avg;
      when ('NYC') output obs.nyc_ip_dx_pr_w_avg;
      when ('LI')  output obs.li_ip_dx_pr_w_avg;
      otherwise output obs.unknown;

   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 May 2016 23:31:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-error-during-datastep/m-p/270237#M53661</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-12T23:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS error during datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-error-during-datastep/m-p/270338#M53695</link>
      <description>Ballardw,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks for the SAS programming tip. It definitely makes for more compact programming.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Steve D&lt;BR /&gt;</description>
      <pubDate>Fri, 13 May 2016 13:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-error-during-datastep/m-p/270338#M53695</guid>
      <dc:creator>nohassles</dc:creator>
      <dc:date>2016-05-13T13:26:55Z</dc:date>
    </item>
  </channel>
</rss>

