<?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: array to big in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/array-to-big/m-p/639226#M190100</link>
    <description>&lt;P&gt;Why do you need an array?&lt;/P&gt;
&lt;P&gt;You have one dataset with patient ZIP codes and a second dataset with provider ZIP code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just join them.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
create table patzip as select ZIP_CD,count(distinct PATIENT) as n_patients&amp;nbsp;from VALID_BENEZ ;
create table provzip as select distinct PROV_ZIP from VALID_PROVZ
create table want as
  select ZIP_CD&amp;nbsp; as pat_zip
       , PROV_ZIP 
       , n_patients
       , ZIPCITYDISTANCE(ZIP_CD,PROVZIPS) as distance
  from patzip, provzip &amp;nbsp;
&amp;nbsp;&amp;nbsp;where&amp;nbsp;calculated&amp;nbsp;distance&amp;nbsp;&amp;lt; 30
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to summarize by provider zip code you can add an additional step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table summary as 
  select prov_zip,sum(n_patients) as n_patients_in_30miles
  from want;
  group by prov_zip
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could then link this back to individual providers by their zip code.&lt;/P&gt;</description>
    <pubDate>Sat, 11 Apr 2020 23:18:04 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-04-11T23:18:04Z</dc:date>
    <item>
      <title>array to big</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-to-big/m-p/639222#M190097</link>
      <description>&lt;P&gt;Hello, I'm trying to do some distance analysis.&amp;nbsp; &amp;nbsp;Basically, I want to determine the share of patients who are with 30 miles of certain medical providers.&amp;nbsp; &amp;nbsp; I grouped patients by zip code and I have a separate list of zip codes where 1 or more of the providers has a practice.&amp;nbsp; &amp;nbsp;For each patient zip code, loop through an array of provider zips and measure the distance for each provider zip code using the ZIPCITYDISTANCE function.&amp;nbsp; &amp;nbsp;I then would take the minimum value of all the distances and that would be distance value for that patient zip code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ran into trouble building the array of provider zip codes because I bumped into the size limit for array values.&amp;nbsp; &amp;nbsp;Can anyone suggest work around?&amp;nbsp; &amp;nbsp;I'm wondering if a hash table might do the same thing without the limit, but am not sure of the syntax.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;200 PROC SQL NOPRINT;&lt;BR /&gt;201 /*CREATE AN ARRY OF PROVIDER ZIP CODES*/&lt;BR /&gt;202 SELECT QUOTE(PROV_ZIP,"'") INTO :ZIPLIST SEPARATED BY ' '&lt;BR /&gt;203 FROM VALID_PROVZ&lt;BR /&gt;204 WHERE VALID=1;&lt;BR /&gt;ERROR: THE LENGTH OF THE VALUE OF THE MACRO VARIABLE ZIPLIST (65540) EXCEEDS THE MAXIMUM LENGTH (65534). THE VALUE HAS BEEN&lt;BR /&gt;TRUNCATED TO 65534 CHARACTERS.&lt;BR /&gt;205 %LET ZIPCNT=&amp;amp;SQLOBS;&lt;BR /&gt;206 %PUT &amp;amp;ZIPCNT;&lt;BR /&gt;8194&lt;BR /&gt;207&lt;BR /&gt;NOTE: THE SAS SYSTEM STOPPED PROCESSING THIS STEP BECAUSE OF ERRORS.&lt;BR /&gt;NOTE: THE PROCEDURE SQL USED 0.05 CPU SECONDS AND 24308K.&lt;/P&gt;&lt;P&gt;NOTE: THE ADDRESS SPACE HAS USED A MAXIMUM OF 1940K BELOW THE LINE AND 650284K ABOVE THE LINE.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;208 DATA CALC_DIST(KEEP=ZIP_CD VALID MINDIST);&lt;BR /&gt;209 SET VALID_BENEZ;&lt;BR /&gt;210 IF ZIP_CD NE '';&lt;/P&gt;&lt;P&gt;211 ARRAY PROVZIPS{&amp;amp;ZIPCNT} $ (&amp;amp;ZIPLIST);&amp;nbsp; &amp;nbsp; /*PROVIDER ZIP CODE ARRAY*/&lt;BR /&gt;212 ARRAY PROVDIST{&amp;amp;ZIPCNT};&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;/*DISTANCE ARRAY*/&lt;BR /&gt;213 IF VALID=1 THEN DO I=1 TO &amp;amp;ZIPCNT;&lt;BR /&gt;214 IF PROVZIPS(I) NE '' THEN PROVDIST(I)=&lt;BR /&gt;NOTE: THE QUOTED STRING CURRENTLY BEING PROCESSED HAS BECOME MORE THAN 262 CHARACTERS LONG. YOU MIGHT HAVE UNBALANCED QUOTATION&lt;BR /&gt;MARKS.&lt;BR /&gt;215 ZIPCITYDISTANCE(ZIP_CD,PROVZIPS(I));&lt;BR /&gt;216 END;&lt;BR /&gt;217 MINDIST=MIN(OF PROVDIST(*));&lt;BR /&gt;218 RUN;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Apr 2020 22:46:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-to-big/m-p/639222#M190097</guid>
      <dc:creator>Batman</dc:creator>
      <dc:date>2020-04-11T22:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: array to big</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-to-big/m-p/639226#M190100</link>
      <description>&lt;P&gt;Why do you need an array?&lt;/P&gt;
&lt;P&gt;You have one dataset with patient ZIP codes and a second dataset with provider ZIP code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just join them.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
create table patzip as select ZIP_CD,count(distinct PATIENT) as n_patients&amp;nbsp;from VALID_BENEZ ;
create table provzip as select distinct PROV_ZIP from VALID_PROVZ
create table want as
  select ZIP_CD&amp;nbsp; as pat_zip
       , PROV_ZIP 
       , n_patients
       , ZIPCITYDISTANCE(ZIP_CD,PROVZIPS) as distance
  from patzip, provzip &amp;nbsp;
&amp;nbsp;&amp;nbsp;where&amp;nbsp;calculated&amp;nbsp;distance&amp;nbsp;&amp;lt; 30
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to summarize by provider zip code you can add an additional step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table summary as 
  select prov_zip,sum(n_patients) as n_patients_in_30miles
  from want;
  group by prov_zip
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could then link this back to individual providers by their zip code.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Apr 2020 23:18:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-to-big/m-p/639226#M190100</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-11T23:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: array to big</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-to-big/m-p/639291#M190148</link>
      <description>&lt;P&gt;You do not have an array problem, you have a macro variable problem.&lt;/P&gt;
&lt;P&gt;This happens because you abuse the macro processor for something that it's not meant for: processing data.&lt;/P&gt;
&lt;P&gt;Use a join or a hash object.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Apr 2020 11:08:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-to-big/m-p/639291#M190148</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-12T11:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: array to big</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-to-big/m-p/639316#M190172</link>
      <description>&lt;P&gt;Thanks, that did work although it took a long time and I also got this message "NOTE: THE EXECUTION OF THIS QUERY INVOLVES PERFORMING ONE OR MORE CARTESIAN PRODUCT JOINS THAT CAN NOT BE OPTIMIZED."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any suggested hash code, I'm wondering it might be more efficient.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Apr 2020 13:28:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-to-big/m-p/639316#M190172</guid>
      <dc:creator>Batman</dc:creator>
      <dc:date>2020-04-12T13:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: array to big</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-to-big/m-p/639317#M190173</link>
      <description>&lt;P&gt;Understood.&amp;nbsp;&amp;nbsp; Do you have any suggested hash code?&amp;nbsp;&amp;nbsp; I've mainly used hash tables as a lookup in the past and this is a little different.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Apr 2020 13:38:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-to-big/m-p/639317#M190173</guid>
      <dc:creator>Batman</dc:creator>
      <dc:date>2020-04-12T13:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: array to big</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-to-big/m-p/639328#M190181</link>
      <description>&lt;P&gt;It is doing a cartesian product on purpose since you want to check the distance for each pair of zip code.&lt;/P&gt;
&lt;P&gt;Make sure to only keep the valid provider zip codes.&lt;/P&gt;
&lt;P&gt;To improve performance you probably will want keep only the zip codes in the provider subset.&amp;nbsp; Then you can remerge with the list of actual providers based on provider zip code once you have the patient counts for that zip code to see the results by provider.&lt;/P&gt;
&lt;P&gt;Not sure hash will improve performance a lot.&amp;nbsp; You might be able to do it in one step with hash and that might improve performance a little by eliminating some of the IO.&amp;nbsp; But you still need to compare every possible pair of zipcodes.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Apr 2020 14:50:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-to-big/m-p/639328#M190181</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-12T14:50:36Z</dc:date>
    </item>
  </channel>
</rss>

