Help using Base SAS procedures

apply format to proc print without var

Accepted Solution Solved
Reply
Regular Contributor
Posts: 204
Accepted Solution

apply format to proc print without var

This works fine:

 

proc format; 
 value Bla 
    low -< -1.0 = "red" 
    -1 -< 0 = "green"
	0 - high = "white"; 
run;

proc print data=Temp NOOBS; 
	var X Y Z
	/style(data) = [background=Bla.];	 
run;

I am in a situation where my vars are dynamic so I cannot use the /style option. Is there a way to apply the above format to all numeric values in the table to be printed?


Accepted Solutions
Solution
‎05-14-2018 08:58 AM
Super User
Super User
Posts: 9,599

Re: apply format to proc print without var

Posted in reply to csetzkorn

You can always use var, even if its a matter of doing:

proc sql;
  select name into :vlist separated by " " 
  from sashelp.vcolumn 
  where libname="WORK" and memname="TEMP";
quit;

proc print data=temp;
  var &vlist.;
run;

"Can't" is not in programming.

As for the issue, the key is to use the _numeric_ SAS command, which means all numeric variables:

proc print data=temp;
  var _numeric_ / style(data)=[background=bla.];
run;

View solution in original post


All Replies
Super User
Super User
Posts: 9,599

Re: apply format to proc print without var

Posted in reply to csetzkorn

Something like:

proc print data=temp noobs;
  var x y z;
  format _numeric_ bla.;
run;
Regular Contributor
Posts: 204

Re: apply format to proc print without var

Thanks. Firstly I cannot use var. Secondly (tried this) but it does not change the background color but prints the format values.
Solution
‎05-14-2018 08:58 AM
Super User
Super User
Posts: 9,599

Re: apply format to proc print without var

Posted in reply to csetzkorn

You can always use var, even if its a matter of doing:

proc sql;
  select name into :vlist separated by " " 
  from sashelp.vcolumn 
  where libname="WORK" and memname="TEMP";
quit;

proc print data=temp;
  var &vlist.;
run;

"Can't" is not in programming.

As for the issue, the key is to use the _numeric_ SAS command, which means all numeric variables:

proc print data=temp;
  var _numeric_ / style(data)=[background=bla.];
run;
Regular Contributor
Posts: 204

Re: apply format to proc print without var

wow this is exactly what I needed (-:
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 169 views
  • 2 likes
  • 2 in conversation