BookmarkSubscribeRSS Feed
thiennguyen19x5
Fluorite | Level 6

Why can I create any names of variables in JMP but I can't do that with SAS?

 

thiennguyen19x5_0-1715523547594.png

 

10 REPLIES 10
PaigeMiller
Diamond | Level 26

Not really sure what your question is.

 

In SAS, with VALIDVARNAME=ANY you have a lot of flexibility about what variable names you can use. Better, however, if you really want SAS variables to appear with virtually any character, you should use labels in SAS when you output the results.

--
Paige Miller
thiennguyen19x5
Fluorite | Level 6

I mean, when I use JMP, I can type anything for a variable name (such as space, non-English language characters, etc.), but I can't do that in SAS. I know JMP also belongs to the SAS Institute. Why don't they change the rules of the SAS variable name for convenience?

PaigeMiller
Diamond | Level 26

@thiennguyen19x5 wrote:

I mean, when I use JMP, I can type anything for a variable name (such as space, non-English language characters, etc.), but I can't do that in SAS. I know JMP also belongs to the SAS Institute. Why don't they change the rules of the SAS variable name for convenience?


Have you tried VALIDVARNAME=ANY in SAS? Apparently you have not despite it being mentioned; but yes, you can have spaces and foreign characters.

 

Just because SAS owns both products (and owned them during the development stage of the software), there's no reason that the two have to have identical rules.

--
Paige Miller
thiennguyen19x5
Fluorite | Level 6

I am a new SAS user; honestly, I haven't tried your method. Maybe I will soon. I am reading the book "The Simple Guide to SAS: From Null to Novice."
If you aren't busy, I hope you can present your method by taking a screenshot. I am happy with your kindness. Thanks

PaigeMiller
Diamond | Level 26
options validvarname=any;
data a;
    'Á var name with-spaces ığñ'n=7;
run;

 

 

But honestly, as I said earlier, in SAS do not make variable names with spaces and foreign characters and special characters unless you absolutely have to. Use the standard SAS variable names, do not turn on VALIDVARNAME=ANY unless you absolutely have to. Instead use VALIDVARNAME=V7 and accept the limits on variable names. WHY? Because long variable names with special characters and foreign characters and spaces belong in SAS labels, not in the variable name. SAS has created a mechanism for your special characters and foreign characters and spaces to be displayed to users in output; that's what labels are for.

--
Paige Miller
thiennguyen19x5
Fluorite | Level 6

I understand that code programs are generally different from point-and-click software (JMP, SPSS, Minitab, etc.). Anyway, I only need to love code; I must be adaptable to the inconvenient code program variable name rule.

Patrick
Opal | Level 21

@thiennguyen19x5 wrote:

I understand that code programs are generally different from point-and-click software (JMP, SPSS, Minitab, etc.). Anyway, I only need to love code; I must be adaptable to the inconvenient code program variable name rule.


You can use variable names in SAS that don't comply with SAS naming conventions. To use them you need to reference them like: '<variable name>'n

It's cumbersome to work with such non-compliant names. Such names will then also be non-compliant in many other programing languages and though will cause even more complication when exchanging data with other environments (like a database).

 

It's normally best to use short and compliant names with a label added for display (or just as a description stored together with the variable name).

data demo;
  attrib 
    myvar 
      format=percent10.2
      label ='This is my numerical variable that displays values in percent'
    'myvar literal $'n
      length=$1
      label="This is another variable where the name doesn't comply with SAS naming conventions"
      ;          ;
  myvar=0.456;
  'myvar literal $'n='A';

run;
proc print data=demo;
run;
proc print data=demo label;
run;

Patrick_0-1715577983290.png

 

ballardw
Super User

I think I have some pity for whoever inherits your code.

I can just see someone spending time trying to type the name of a variable that looks like "this v▒ has null characters"n. Can you see which of the two spaces are actually null characters? Much less dealing with other special characters entered with high order ASCII (numbers above 127) where a different makes makes the name look different?

 

I realize that there are languages that don't do will with ASCII. But if your language doesn't require something like UNICODE and such don't complicate coding anymore than needed.

Quentin
Super User

While JMP and SAS were created by the same company, they are very separate products / languages.  JMP was released in 1989.  SAS was almost 20 years old already.  At the time, SAS variable names were limited to 8 characters long.  SAS added support for longer variable names over time, but there are probably plenty of features you'll find in JMP that are not in SAS.  The two products have different histories, and different roadmaps for the future.

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
andreas_lds
Jade | Level 19

With validvarname=any i can do this without using the ugly name-literals:

data work.Class;
    set sashelp.class;

    rename
        Sex = Gechlecht
        Age = Alter
        Height = Größe
        Weight = Gewicht
    ;
run;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 10 replies
  • 2185 views
  • 9 likes
  • 6 in conversation