<?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: How to get SQL proc output to a micro variable vector? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-SQL-proc-output-to-a-micro-variable-vector/m-p/333485#M75140</link>
    <description>&lt;P&gt;Thanks for your kind reply, I got some success given below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Baar 13,Basel 14,Biel 2,Cham 2,Dietikon 4,DÃƒÆ’Ã‚Â¼bendorf 2,Geneva 47,Kloten 5,Lausanne 5,Luzein 6,Neuchactel 1,OTHER 119,Olten&lt;BR /&gt;1,PfÃƒÆ’Ã‚Â¤ffikon 2,Rotkreuz 1,Schaffhausen 3,St. Gallen 2,Wallisellen 3,Winterthur 2,Zug 19,Zurich 246&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But&amp;nbsp;i need output as given below. So that i can use the output for bar plot of city with the given value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obs city COUNT&lt;/P&gt;&lt;P&gt;1 Baar 13&lt;BR /&gt;2 Basel 14&lt;BR /&gt;3 Biel 2&lt;BR /&gt;4 Cham 2&lt;BR /&gt;5 Dietikon 4&lt;BR /&gt;6 DÃƒÆ’Ã‚Â¼bendorf 2&lt;BR /&gt;7 Geneva 47&lt;BR /&gt;8 Kloten 5&lt;BR /&gt;9 Lausanne 5&lt;BR /&gt;10 Luzein 6&lt;BR /&gt;11 Neuchactel 1&lt;BR /&gt;12 OTHER 119&lt;BR /&gt;13 Olten 1&lt;BR /&gt;14 PfÃƒÆ’Ã‚Â¤ffikon 2&lt;BR /&gt;15 Rotkreuz 1&lt;BR /&gt;16 Schaffhausen 3&lt;BR /&gt;17 St. Gallen 2&lt;BR /&gt;18 Wallisellen 3&lt;BR /&gt;19 Winterthur 2&lt;BR /&gt;20 Zug 19&lt;BR /&gt;21 Zurich 246&lt;/P&gt;</description>
    <pubDate>Thu, 16 Feb 2017 17:23:53 GMT</pubDate>
    <dc:creator>ervinodsingh</dc:creator>
    <dc:date>2017-02-16T17:23:53Z</dc:date>
    <item>
      <title>How to get SQL proc output to a micro variable vector?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-SQL-proc-output-to-a-micro-variable-vector/m-p/333364#M75098</link>
      <description>&lt;P&gt;Hi i have returned SQL output using macro, but my results are returned as city name concatenated as a string and customers count in each city as a single concatenated string all are separated&amp;nbsp;by space as code is given below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But i want these strings as a vector of cities and a vector of customer counts to create a data in SAS. Please help me&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql NOPRINT;&lt;BR /&gt;select city, count(*) into :cit seperated by ' ',&lt;BR /&gt;:fre seperated by ' '&lt;BR /&gt;from WORK.input&lt;BR /&gt;WHERE customer= 1&lt;BR /&gt;group by city;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%put &amp;amp;cit;&lt;BR /&gt;%put &amp;amp;fre;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"&lt;/P&gt;&lt;P&gt;Obs &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;city&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Baar Basel Biel Cham Dietikon DÃƒÆ’Ã‚Â¼bendorf Geneva Kloten Lausanne Luzein Neuchactel OTHER Olten PfÃƒÆ’Ã‚Â¤ffikon Rotkreuz&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obs &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;frequ&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 13 14 2 2 4 2 47 5 5 6 1 119 1 2 1 3 2 3 2 19 246&lt;/P&gt;&lt;P&gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to generate sas data as&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Baar &amp;nbsp;13&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Basel 14&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Rotkreuz 246&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 13:06:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-SQL-proc-output-to-a-micro-variable-vector/m-p/333364#M75098</guid>
      <dc:creator>ervinodsingh</dc:creator>
      <dc:date>2017-02-16T13:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to get SQL proc output to a micro variable vector?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-SQL-proc-output-to-a-micro-variable-vector/m-p/333369#M75099</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not sure I understand your question.&lt;/P&gt;
&lt;P&gt;If you want to create a dataset that contains the number of occurrences of each city name&lt;/P&gt;
&lt;P&gt;for customer 1 then you can create the dataset directly in the proc sql without having&lt;/P&gt;
&lt;P&gt;to export your data into macrovariables :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
    CREATE TABLE want AS
    SELECT CITY, count(*) AS CITY_COUNT
    FROM WORK.input
    WHERE customer= 1
    GROUP BY city;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Feb 2017 13:43:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-SQL-proc-output-to-a-micro-variable-vector/m-p/333369#M75099</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2017-02-16T13:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to get SQL proc output to a micro variable vector?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-SQL-proc-output-to-a-micro-variable-vector/m-p/333370#M75100</link>
      <description>&lt;P&gt;Good morning,&lt;/P&gt;&lt;P&gt;I am not sure I understand your question.&lt;/P&gt;&lt;P&gt;If you want to print your result, i propose this solution:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _null_;
SET sashelp.class end=last;
call symputx ('col1'||LEFT(_n_),LEFT(name));
call symputx ('col2'||LEFT(_n_),LEFT(sex));
if last then call symput ('nbr',_n_);
run;

%macro mamacro();
   DATA _null_;
      put "name"  %str('     ')    "Sex"; 
      %do i=1 %to &amp;amp;nbr;
      put "&amp;amp;&amp;amp;col1&amp;amp;i" %str( '     ' ) "&amp;amp;&amp;amp;col2&amp;amp;i" ;

%end;
 
run;
%mend ;
%mamacro;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 13:53:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-SQL-proc-output-to-a-micro-variable-vector/m-p/333370#M75100</guid>
      <dc:creator>mansour_ibrahim</dc:creator>
      <dc:date>2017-02-16T13:53:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to get SQL proc output to a micro variable vector?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-SQL-proc-output-to-a-micro-variable-vector/m-p/333379#M75104</link>
      <description>&lt;P&gt;I don't think it is possible in one pass, you need to count in a sub-select and then create your macro variable string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select catx(' ',name, counts)
    into : names separated by ','
  from (
    select name, count(*) as counts
    from sashelp.class
    group by name )
  ;
quit;
%put &amp;amp;names ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which would give:&lt;/P&gt;
&lt;P&gt;%put &amp;amp;names ;&lt;BR /&gt;Alfred 1,Alice 1,Barbara 1,Carol 1,Henry 1,James 1,Jane 1,Janet 1,Jeffrey 1,John 1,Joyce 1,Judy&lt;BR /&gt;1,Louise 1,Mary 1,Philip 1,Robert 1,Ronald 1,Thomas 1,William 1&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 14:13:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-SQL-proc-output-to-a-micro-variable-vector/m-p/333379#M75104</guid>
      <dc:creator>MichaelLarsen</dc:creator>
      <dc:date>2017-02-16T14:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to get SQL proc output to a micro variable vector?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-SQL-proc-output-to-a-micro-variable-vector/m-p/333381#M75106</link>
      <description>&lt;P&gt;This seems to work :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select catx(' ',name, count(*))
  into :names separated by ','
  from sashelp.class
  group by name 
  ;
quit;

%put &amp;amp;names.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Feb 2017 14:20:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-SQL-proc-output-to-a-micro-variable-vector/m-p/333381#M75106</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2017-02-16T14:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to get SQL proc output to a micro variable vector?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-SQL-proc-output-to-a-micro-variable-vector/m-p/333477#M75136</link>
      <description>&lt;P&gt;Hi Thanks a lot for your help, I have got the desired output (given below). As I have started SAS programming just two days ago. I may be poor in basic things about SAS. I found somewhere&amp;nbsp;to use macro variables&amp;nbsp;to hold values for future like plotting, hence, i was trying to that way . But, i still have one problem how can i use this output for bar plot. corresponding to the city and its value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CITY_&lt;BR /&gt;Obs city COUNT&lt;/P&gt;&lt;P&gt;1 Baar 13&lt;BR /&gt;2 Basel 14&lt;BR /&gt;3 Biel 2&lt;BR /&gt;4 Cham 2&lt;BR /&gt;5 Dietikon 4&lt;BR /&gt;6 DÃƒÆ’Ã‚Â¼bendorf 2&lt;BR /&gt;7 Geneva 47&lt;BR /&gt;8 Kloten 5&lt;BR /&gt;9 Lausanne 5&lt;BR /&gt;10 Luzein 6&lt;BR /&gt;11 Neuchactel 1&lt;BR /&gt;12 OTHER 119&lt;BR /&gt;13 Olten 1&lt;BR /&gt;14 PfÃƒÆ’Ã‚Â¤ffikon 2&lt;BR /&gt;15 Rotkreuz 1&lt;BR /&gt;16 Schaffhausen 3&lt;BR /&gt;17 St. Gallen 2&lt;BR /&gt;18 Wallisellen 3&lt;BR /&gt;19 Winterthur 2&lt;BR /&gt;20 Zug 19&lt;BR /&gt;21 Zurich 246&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 17:11:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-SQL-proc-output-to-a-micro-variable-vector/m-p/333477#M75136</guid>
      <dc:creator>ervinodsingh</dc:creator>
      <dc:date>2017-02-16T17:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to get SQL proc output to a micro variable vector?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-SQL-proc-output-to-a-micro-variable-vector/m-p/333485#M75140</link>
      <description>&lt;P&gt;Thanks for your kind reply, I got some success given below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Baar 13,Basel 14,Biel 2,Cham 2,Dietikon 4,DÃƒÆ’Ã‚Â¼bendorf 2,Geneva 47,Kloten 5,Lausanne 5,Luzein 6,Neuchactel 1,OTHER 119,Olten&lt;BR /&gt;1,PfÃƒÆ’Ã‚Â¤ffikon 2,Rotkreuz 1,Schaffhausen 3,St. Gallen 2,Wallisellen 3,Winterthur 2,Zug 19,Zurich 246&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But&amp;nbsp;i need output as given below. So that i can use the output for bar plot of city with the given value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obs city COUNT&lt;/P&gt;&lt;P&gt;1 Baar 13&lt;BR /&gt;2 Basel 14&lt;BR /&gt;3 Biel 2&lt;BR /&gt;4 Cham 2&lt;BR /&gt;5 Dietikon 4&lt;BR /&gt;6 DÃƒÆ’Ã‚Â¼bendorf 2&lt;BR /&gt;7 Geneva 47&lt;BR /&gt;8 Kloten 5&lt;BR /&gt;9 Lausanne 5&lt;BR /&gt;10 Luzein 6&lt;BR /&gt;11 Neuchactel 1&lt;BR /&gt;12 OTHER 119&lt;BR /&gt;13 Olten 1&lt;BR /&gt;14 PfÃƒÆ’Ã‚Â¤ffikon 2&lt;BR /&gt;15 Rotkreuz 1&lt;BR /&gt;16 Schaffhausen 3&lt;BR /&gt;17 St. Gallen 2&lt;BR /&gt;18 Wallisellen 3&lt;BR /&gt;19 Winterthur 2&lt;BR /&gt;20 Zug 19&lt;BR /&gt;21 Zurich 246&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 17:23:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-SQL-proc-output-to-a-micro-variable-vector/m-p/333485#M75140</guid>
      <dc:creator>ervinodsingh</dc:creator>
      <dc:date>2017-02-16T17:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to get SQL proc output to a micro variable vector?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-SQL-proc-output-to-a-micro-variable-vector/m-p/333490#M75142</link>
      <description>&lt;P&gt;For some simple charts such as the count of a category you do not even need to summarize the data. You can request some statistics in the graph procedure.&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;PRE&gt;proc sort data=work.input;
   by customer;
run;
proc sqplot data=WORK.input;
   by customer;
   vbar city /stat=freq   ;
run;&lt;/PRE&gt;
&lt;P&gt;should produce a graph for each customer and vertical bar showing the count (Freq) of each city for that customer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Things may get crowded it you have a lot of cities though.&lt;/P&gt;
&lt;P&gt;You could place a: Where customer=1; in the sgplot to restrict the plot to one customer, or Where customer in (1 ,3, 5); to select specific customers.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 17:26:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-SQL-proc-output-to-a-micro-variable-vector/m-p/333490#M75142</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-02-16T17:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to get SQL proc output to a micro variable vector?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-SQL-proc-output-to-a-micro-variable-vector/m-p/333497#M75143</link>
      <description>&lt;P&gt;Actually, the above-obtained table from the given query in the code you provided, gave me the number of customers for each city, Now,&amp;nbsp; want to plot the number of customers as bar&amp;nbsp;plot for each city. Thanks &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 17:48:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-SQL-proc-output-to-a-micro-variable-vector/m-p/333497#M75143</guid>
      <dc:creator>ervinodsingh</dc:creator>
      <dc:date>2017-02-16T17:48:10Z</dc:date>
    </item>
  </channel>
</rss>

