Display and export both column names and labels

Reply
New Contributor
Posts: 4

Display and export both column names and labels

Is that possible to display both column names and labels? I have a sas file that has both, but for some reason I can't get JMP11 display (or export) both labels and names in the first row.

Thanks!

PROC Star
Posts: 7,364

Re: Display and export both column names and labels

You posted this, again, on the main discussion board.  You first have to click on the link for the JMP forum then, once there, post your question.

While I'm not familiar with JMP, my guess is that it is either using, or using something like, SAS's viewtable.

If so, it can only show EITHER variable names, or variable labels, but not both.  If it is using the SAS/AF viewtable command, there should be a way to toggle between the two choices.

New Contributor
Posts: 4

Re: Display and export both column names and labels

First - I apologize for posting twice in the wrong forum! Second - the solution, it seems, is to use an add-in (found here:Switch
to short or long names
) and then export two tables, one with short names and then one with long names. I can then do the name merging in Excel. My goal was to get the column names look like : "SAS Label (SAS Name)". Very lengthy solution, but I haven't found a better one yet.

PROC Star
Posts: 7,364

Re: Display and export both column names and labels

Since that was John's suggestion and he is THE John in John's Macintosh Program (i.e., JMP), I'd think you might have already found a good solution.  If you also license SAS you could, of course, create a 2nd file that combines the variable names and labels into the label, exactly as you want them, and then only view the labels as headers.

Super Contributor
Posts: 644

Re: Display and export both column names and labels

If you do have access to SAS you can create the combined labels before you import to JMP.

Data have ;

     Length id    8

               Prod $16

               PP    8

               ;

     Label  id          =      "Identifier"

               Prod     =     "Product Name"

               PP        =     "Purchase Price"

               ;

Run ;

 

/*     No data in table but not needed for this demo     */

Proc  SQL ;

     Select CATX (" ", Name, "=", QUOTE (CATT (label, ' (', Name, ')')))

          into :NewLabels

          separated by " "

     From Dictionary.columns

     Where Libname = 'WORK'

          and Memname = 'HAVE'

;

Quit  ;

/*     Must use caps     */

Data want ;

     Set have ;

     Label &NewLabels ;

Run ;

[tested code - SAS EG with version 9.3 on the server]

This solution saves the code for the new labels in a macro variable.  It should work for at least 200 variables, even if both variable names and labels are of maximum length.  You can check whether the length of the macro variable is at risk of running into the limit using

     %Put %Length (&NewLabels) ;

- any value near 65534 should raise alarms.

Having said that I do not know what the limit is for the length of a column name in JMP but I suspect it is less than the 254 characters allowed for a label in SAS 9.3 so some truncation may occur.

Richard in NZ

Ask a Question
Discussion stats
  • 4 replies
  • 629 views
  • 0 likes
  • 3 in conversation