turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- Underscore in variable names in Distance Matrix

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-27-2016 02:51 AM

I am trying to create a distance matrix with the following piece of code

proc distance data=sample shape=SQR out=Dist method=Euclid ;

var interval(a2--a6 / std=Std);

id a1;

run;

Although I am getting the output but all the variable names its taking from a1 have an underscore before it, for example a1 has values 1,2 ,3 ,4 ,5 ....and so, and in the distance matrix the variable names become _1, _2, _3, _4, _5... and so on.

Could anybody please tell me the reason and guide me the way to remove the same.

Thanks in advance !

Accepted Solutions

Solution

07-28-2016
01:29 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-27-2016 03:09 AM

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-27-2016 03:02 AM

A SAS name cannot begin with a numerical digit (0 .. 9).

Therefore, when SAS has to automatically create variable names from numerical values, it prefixes the underline.

If you want this to be different, make a1 of type char, containing valid names.

You also might want to consider using the prefix= option in the proc distance statement.

---------------------------------------------------------------------------------------------

Maxims of Maximally Efficient SAS Programmers

Maxims of Maximally Efficient SAS Programmers

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-27-2016 03:05 AM

SAS variable names can't start with a number so to get around that fact it adds an underscore.

I think you'd have to change your variable to start with a character to correct this 😕

Solution

07-28-2016
01:29 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-27-2016 03:09 AM