<?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 do I do univariate graphs for all variable in a dataset and output in vector format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-do-univariate-graphs-for-all-variable-in-a-dataset-and/m-p/779759#M248403</link>
    <description>&lt;P&gt;Dear&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the suggestions,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using a normal macro was a partial solution, but I was able to solve it entirely using a post from Reeza (maybe the same &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;of this thread) in StackOverflow (&lt;A href="https://stackoverflow.com/questions/37017789/sas-creating-plots-for-all-variables" target="_blank" rel="noopener"&gt;https://stackoverflow.com/questions/37017789/sas-creating-plots-for-all-variables&lt;/A&gt;).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just made some additions to do the bar graphs and export as EMF, please see below (with some labels in portuguese).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much, especially to Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best wishes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;ods graphics on/reset imagefmt=EMF;
ods rtf file="graficoshistogramas.rtf" path="your path here"
style=sty_custom;

proc sql noprint;
select name into :hist_state1- 
from dictionary.columns
where upper(libname)='WORK'
and upper(memname)='MERGE0'
and type='num';
quit;

%let nobs=&amp;amp;sqlobs;


%macro generate_histogram;

%do i=1 %to &amp;amp;nobs;

proc sgplot data=WORK.MERGE0;
title "Histograma de &amp;amp;&amp;amp;&amp;amp;hist_state&amp;amp;i";
histogram &amp;amp;&amp;amp;&amp;amp;hist_state&amp;amp;i;
run;quit;


%end;

%mend;

%generate_histogram;











ods graphics on/reset imagefmt=EMF;
ods rtf file="graficosbarrafreq.rtf" path="your path here"
style=sty_custom;

proc sql noprint;
select name into :hist_state1- 
from dictionary.columns
where upper(libname)='WORK'
and upper(memname)='MERGE0'
and type='char';
quit;

%let nobs=&amp;amp;sqlobs;


%macro generate_bar;

%do i=1 %to &amp;amp;nobs;

proc sgplot data=WORK.MERGE0;
title "Grafico de barras de &amp;amp;&amp;amp;&amp;amp;hist_state&amp;amp;i";
vbar &amp;amp;&amp;amp;&amp;amp;hist_state&amp;amp;i /datalabel;
xaxis display=(noline noticks);
yaxis display=(noline) grid label="contagem";
run;quit;


%end;

%mend;

%generate_bar;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 11 Nov 2021 12:21:01 GMT</pubDate>
    <dc:creator>HermanoRocha</dc:creator>
    <dc:date>2021-11-11T12:21:01Z</dc:date>
    <item>
      <title>How do I do univariate graphs for all variable in a dataset and output in vector format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-do-univariate-graphs-for-all-variable-in-a-dataset-and/m-p/779028#M248070</link>
      <description>Dear&lt;BR /&gt;I perform a repetitive task which is to generate univariate graphs of all variables from different databases weekly, bar graphs for categoricals and histograms for numeric ones, with publication formatting (apa), and export as emf to a RTF file, because I need the vector format. currently I have to create the graphs one by one, manually (banks with a few hundred variables). Does anyone have any suggestions on how I could try to automate this activity in sas 9.4?&lt;BR /&gt;Thank you very much for the attention of the community.</description>
      <pubDate>Sun, 07 Nov 2021 21:37:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-do-univariate-graphs-for-all-variable-in-a-dataset-and/m-p/779028#M248070</guid>
      <dc:creator>HermanoRocha</dc:creator>
      <dc:date>2021-11-07T21:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do univariate graphs for all variable in a dataset and output in vector format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-do-univariate-graphs-for-all-variable-in-a-dataset-and/m-p/779031#M248072</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need dynamic and generic code that is adapted depending on the variables that it finds in your databases.&lt;/P&gt;
&lt;P&gt;You should use the dictionary tables and you need a program that writes another program (and the latter should be submitted).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In SAS, there are many techniques to avoid 'hard-coding' things and to generate dynamic code.&lt;/P&gt;
&lt;P&gt;You can use macro's or you can use data-driven code generation with FILE statement &amp;amp; PUT stmt. &amp;amp; %INCLUDE or you can use CALL EXECUTE.&lt;BR /&gt;&lt;BR /&gt;I have not read below article, but I think it deals with exactly this.&lt;BR /&gt;Have a look :&lt;/P&gt;
&lt;P&gt;Data-Driven Programming Techniques Using SAS®&lt;BR /&gt;Posted 03-15-2021 09:43 AM | by KirkLafler&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Global-Forum-Proceedings/Data-Driven-Programming-Techniques-Using-SAS/ta-p/726293" target="_blank"&gt;https://communities.sas.com/t5/SAS-Global-Forum-Proceedings/Data-Driven-Programming-Techniques-Using-SAS/ta-p/726293&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sun, 07 Nov 2021 21:48:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-do-univariate-graphs-for-all-variable-in-a-dataset-and/m-p/779031#M248072</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-11-07T21:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do univariate graphs for all variable in a dataset and output in vector format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-do-univariate-graphs-for-all-variable-in-a-dataset-and/m-p/779157#M248122</link>
      <description>Seems like you're generating data profiles?&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Demographic-Table-and-Subgroup-Summary-Macro-TABLEN/ta-p/634030" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Demographic-Table-and-Subgroup-Summary-Macro-TABLEN/ta-p/634030&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Survival example from my days in cancer research, quick survival profiles on data:&lt;BR /&gt;&lt;A href="https://gist.github.com/statgeek/d3bce2a9e2ef0523db9d" target="_blank"&gt;https://gist.github.com/statgeek/d3bce2a9e2ef0523db9d&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 08 Nov 2021 16:33:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-do-univariate-graphs-for-all-variable-in-a-dataset-and/m-p/779157#M248122</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-08T16:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do univariate graphs for all variable in a dataset and output in vector format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-do-univariate-graphs-for-all-variable-in-a-dataset-and/m-p/779158#M248123</link>
      <description>&lt;P&gt;FYI - start by getting a program that works for a single variable and then generalize it using the tutorial below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;UCLA introductory tutorial on macro variables and macros&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Tutorial on converting a working program to a macro&lt;/STRONG&gt;&lt;BR /&gt;This method is pretty robust and helps prevent errors and makes it much easier to debug your code. Obviously biased, because I wrote it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Examples of common macro usage&lt;/STRONG&gt;&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Nov 2021 16:34:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-do-univariate-graphs-for-all-variable-in-a-dataset-and/m-p/779158#M248123</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-08T16:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do univariate graphs for all variable in a dataset and output in vector format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-do-univariate-graphs-for-all-variable-in-a-dataset-and/m-p/779160#M248125</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;,&amp;nbsp;I use tablen macro a lot, I wish now to complement with graphs,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best wishes&lt;/P&gt;</description>
      <pubDate>Mon, 08 Nov 2021 16:54:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-do-univariate-graphs-for-all-variable-in-a-dataset-and/m-p/779160#M248125</guid>
      <dc:creator>HermanoRocha</dc:creator>
      <dc:date>2021-11-08T16:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do univariate graphs for all variable in a dataset and output in vector format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-do-univariate-graphs-for-all-variable-in-a-dataset-and/m-p/779181#M248133</link>
      <description>&lt;P&gt;With RTF output to create EMF graphic output&amp;nbsp; you would set&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ods graphics /outputfmt=emf;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Typically I set all the graphic options before the ODS destination statement.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Nov 2021 18:15:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-do-univariate-graphs-for-all-variable-in-a-dataset-and/m-p/779181#M248133</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-11-08T18:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do univariate graphs for all variable in a dataset and output in vector format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-do-univariate-graphs-for-all-variable-in-a-dataset-and/m-p/779759#M248403</link>
      <description>&lt;P&gt;Dear&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the suggestions,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using a normal macro was a partial solution, but I was able to solve it entirely using a post from Reeza (maybe the same &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;of this thread) in StackOverflow (&lt;A href="https://stackoverflow.com/questions/37017789/sas-creating-plots-for-all-variables" target="_blank" rel="noopener"&gt;https://stackoverflow.com/questions/37017789/sas-creating-plots-for-all-variables&lt;/A&gt;).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just made some additions to do the bar graphs and export as EMF, please see below (with some labels in portuguese).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much, especially to Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best wishes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;ods graphics on/reset imagefmt=EMF;
ods rtf file="graficoshistogramas.rtf" path="your path here"
style=sty_custom;

proc sql noprint;
select name into :hist_state1- 
from dictionary.columns
where upper(libname)='WORK'
and upper(memname)='MERGE0'
and type='num';
quit;

%let nobs=&amp;amp;sqlobs;


%macro generate_histogram;

%do i=1 %to &amp;amp;nobs;

proc sgplot data=WORK.MERGE0;
title "Histograma de &amp;amp;&amp;amp;&amp;amp;hist_state&amp;amp;i";
histogram &amp;amp;&amp;amp;&amp;amp;hist_state&amp;amp;i;
run;quit;


%end;

%mend;

%generate_histogram;











ods graphics on/reset imagefmt=EMF;
ods rtf file="graficosbarrafreq.rtf" path="your path here"
style=sty_custom;

proc sql noprint;
select name into :hist_state1- 
from dictionary.columns
where upper(libname)='WORK'
and upper(memname)='MERGE0'
and type='char';
quit;

%let nobs=&amp;amp;sqlobs;


%macro generate_bar;

%do i=1 %to &amp;amp;nobs;

proc sgplot data=WORK.MERGE0;
title "Grafico de barras de &amp;amp;&amp;amp;&amp;amp;hist_state&amp;amp;i";
vbar &amp;amp;&amp;amp;&amp;amp;hist_state&amp;amp;i /datalabel;
xaxis display=(noline noticks);
yaxis display=(noline) grid label="contagem";
run;quit;


%end;

%mend;

%generate_bar;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Nov 2021 12:21:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-do-univariate-graphs-for-all-variable-in-a-dataset-and/m-p/779759#M248403</guid>
      <dc:creator>HermanoRocha</dc:creator>
      <dc:date>2021-11-11T12:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do univariate graphs for all variable in a dataset and output in vector format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-do-univariate-graphs-for-all-variable-in-a-dataset-and/m-p/779882#M248441</link>
      <description>Yup, that's my solution from SO....5 years ago &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;</description>
      <pubDate>Fri, 12 Nov 2021 01:01:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-do-univariate-graphs-for-all-variable-in-a-dataset-and/m-p/779882#M248441</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-12T01:01:52Z</dc:date>
    </item>
  </channel>
</rss>

