<?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: proc print - dynamic vars in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-dynamic-vars/m-p/461845#M70371</link>
    <description>&lt;P&gt;Well, i suppose you can do away with your var statement&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data w;
set sashelp.class;
run;

proc print data=w noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and let sas list the N number of vars in the input dataset by default without you having to mention it.&lt;/P&gt;&lt;P&gt;Or am i missing something here?&lt;/P&gt;</description>
    <pubDate>Sun, 13 May 2018 16:13:00 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-05-13T16:13:00Z</dc:date>
    <item>
      <title>proc print - dynamic vars</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-dynamic-vars/m-p/461842#M70368</link>
      <description>&lt;P&gt;I am using this code (simplified) in a macro:&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 TRANSPOSE data=Temp out=TransTemp (drop=_:);
	by Range;
	var SomeVar;
	id Segment;
run;

proc print data=TransTemp NOOBS; 
	var Range 	
		x	
		y
		z
	;
	format 
		x
		y
		z NLMNLGBP. 
	; 	
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Unfortunately I sometimes only have a subset of the above columns (x, y, z) present in TransTemp. Is there anything I can do to adjust the code to dynamically adapt - i.e. macrotise it somehow?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 May 2018 15:38:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-dynamic-vars/m-p/461842#M70368</guid>
      <dc:creator>csetzkorn</dc:creator>
      <dc:date>2018-05-13T15:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: proc print - dynamic vars</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-dynamic-vars/m-p/461843#M70369</link>
      <description>&lt;P&gt;not sure if I understood your question&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. do you want to list all your variable names in your transtemp dataset&lt;/P&gt;&lt;P&gt;2. is the problem to do with listing fewer variale names in var statement when there are fewer vars in transtemp?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 May 2018 15:46:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-dynamic-vars/m-p/461843#M70369</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-13T15:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: proc print - dynamic vars</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-dynamic-vars/m-p/461844#M70370</link>
      <description>&lt;P&gt;Thanks for the reply. Yes 2 is the problem ...&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 May 2018 16:02:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-dynamic-vars/m-p/461844#M70370</guid>
      <dc:creator>csetzkorn</dc:creator>
      <dc:date>2018-05-13T16:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: proc print - dynamic vars</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-dynamic-vars/m-p/461845#M70371</link>
      <description>&lt;P&gt;Well, i suppose you can do away with your var statement&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data w;
set sashelp.class;
run;

proc print data=w noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and let sas list the N number of vars in the input dataset by default without you having to mention it.&lt;/P&gt;&lt;P&gt;Or am i missing something here?&lt;/P&gt;</description>
      <pubDate>Sun, 13 May 2018 16:13:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-dynamic-vars/m-p/461845#M70371</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-13T16:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: proc print - dynamic vars</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-dynamic-vars/m-p/461847#M70373</link>
      <description>&lt;P&gt;Sorry no I cannot (I think) as I want to format them. I am using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format 
		x	
		y
		z percent7.1 
		; 	&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;or&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format; 
 value Bla
    low -&amp;lt; -1.0 = "red" 
    -1 -&amp;lt; 0 = "green"
	0 - high = "white"; 
run;

...

/style(data) = [background=Bla.]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;in my proc print statement.&lt;/P&gt;</description>
      <pubDate>Sun, 13 May 2018 16:16:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-dynamic-vars/m-p/461847#M70373</guid>
      <dc:creator>csetzkorn</dc:creator>
      <dc:date>2018-05-13T16:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: proc print - dynamic vars</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-dynamic-vars/m-p/461848#M70374</link>
      <description>&lt;P&gt;You can use proc format and define all formats you need independenly from variables you want to use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming you want to print &lt;STRONG&gt;part&lt;/STRONG&gt; of the variables in the dataset you can use KEEP statement, to keep wanted variables,&lt;/P&gt;
&lt;P&gt;in the PROC PRINT procedure.&lt;/P&gt;
&lt;P&gt;You can define the variables using %LET staement preceding the proc print:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let vars = x y;  /* list of wanted variables */

proc print data=w(keep=&amp;amp;vars) noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In case you want to print all varaibles, you can assign vars to _ALL_;&lt;/P&gt;</description>
      <pubDate>Sun, 13 May 2018 16:51:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-dynamic-vars/m-p/461848#M70374</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-05-13T16:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: proc print - dynamic vars</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-print-dynamic-vars/m-p/461850#M70375</link>
      <description>&lt;P&gt;Try this format statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;format _numeric_ NLMNLGBP. range;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may not need to add RANGE to the list, if it is character.&amp;nbsp; This statement assigns the format to all numeric variables being printed, but then removes any format assigned to RANGE.&lt;/P&gt;</description>
      <pubDate>Sun, 13 May 2018 17:37:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-print-dynamic-vars/m-p/461850#M70375</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-05-13T17:37:19Z</dc:date>
    </item>
  </channel>
</rss>

