BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
paddyb
Quartz | Level 8

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.

1 ACCEPTED SOLUTION

Accepted Solutions
ABritinAus
Obsidian | Level 7

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

6 REPLIES 6
ABritinAus
Obsidian | Level 7

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.

 

 

 

 

 

Cynthia_sas
SAS Super FREQ

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

paddyb
Quartz | Level 8

Thank you

Jagadishkatam
Amethyst | Level 16

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
paddyb
Quartz | Level 8
yes i was using it for column header
column frq_-1 freq_1 freq_2;
Cynthia_sas
SAS Super FREQ
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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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