The SAS Output Delivery System and reporting techniques

proc report column statement

Accepted Solution Solved
Reply
Contributor
Posts: 33
Accepted Solution

proc report column statement

I would like to use column header as frq_-1 but it gives error for'-' ,Is there any way to use it on column statement in proc report.

Thanks you.


Accepted Solutions
Solution
‎07-03-2017 11:15 PM
Contributor
Posts: 33

Re: proc report column statement

Hi Paddy

 

To clarify: your variable is called frq_-1?? 

 

You should be able to use it in a column statement by specifying

 

'frq_-1'n  as the reference to that variable in the column statement.

 

If that's not what you were asking, let me know.

 

 

 

 

 

View solution in original post


All Replies
Solution
‎07-03-2017 11:15 PM
Contributor
Posts: 33

Re: proc report column statement

Hi Paddy

 

To clarify: your variable is called frq_-1?? 

 

You should be able to use it in a column statement by specifying

 

'frq_-1'n  as the reference to that variable in the column statement.

 

If that's not what you were asking, let me know.

 

 

 

 

 

SAS Super FREQ
Posts: 8,743

Re: proc report column statement

[ Edited ]

Hi:
In addition, no matter what your variables are named, you can always tell PROC REPORT to use some other string as the column header for the report:
   
proc report data=sashelp.class;
  column name age height weight;
  define name / display 'frq_-1';
  define age / display 'xyz_-2';
run;

cynthia

Contributor
Posts: 33

Re: proc report column statement

Thank you

Trusted Advisor
Posts: 1,130

Re: proc report column statement

I think if it is a column header (column label) then you should not get any error. Could you please show us how you are applying this in a code

Thanks,
Jag
Contributor
Posts: 33

Re: proc report column statement

yes i was using it for column header
column frq_-1 freq_1 freq_2;
SAS Super FREQ
Posts: 8,743

Re: proc report column statement

Hi:
The COLUMN statement needs variable names and the name "frq_-1" is invalid for a variable name. The rules for naming variables are that the name has to start with a letter or an underscore and continue with any combination of letters, numbers and underscores. A SAS variable name cannot have special characters (such as dash - or space or #, etc). So what you show should have received an error message back when you created it or first read this data into SAS.

You can, if you choose, use name tokens as variable names. Name tokens allow special characters and I generally argue against using them unless you are reading database data and the database allows special characters. But even then, I will recommend renaming the variables to conform, to make your life easier. A name token looks like this in code:

'Job Title'n
'frq_-1'n
'year #2'n

Note the use of quotes and the n indicator -- that is how you reference a name token or name literal (basically, a non-conforming name) in code. But I am not sure that it is warranted in this case.

I recommend going back before your PROC REPORT step, where you first try to create this variable and make sure that you really are creating the variable correctly and try using a conforming name for the variable and then use frq_-1 as the label.

cynthia
☑ This topic is SOLVED.

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

Discussion stats
  • 6 replies
  • 326 views
  • 3 likes
  • 4 in conversation