Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Wrong label using splitvallabels

    Dear all,

    I am having wrong labels using ssc splitvallabels and ssc catplot. example:

    Code:
    clear all
    sysuse auto
    
    splitvallabels foreign, length(8) local(vari)  
    
    catplot , over(foreign, relabel(`vari')) percent
    Click image for larger version

Name:	Graph1.png
Views:	1
Size:	26.1 KB
ID:	1783921



    without relabel:

    Code:
    catplot , over(foreign) percent
    Click image for larger version

Name:	Graph2.png
Views:	1
Size:	26.3 KB
ID:	1783922

    Last edited by Rodrigo Badilla; 23 Dec 2025, 12:41.

  • #2
    splitvallabels and catplot are from SSC, as you are asked to explain in FAQ Advice #12. catplot is a wrapper for graph bar and graph hbar. It is a misconception that the -relabel()- option of graph bar specifies values corresponding to value labels. It does not; it only specifies the order of bars in the graph, starting from 1 and increasing in increments of 1. Therefore, the mapping from value labels to the graph order should be handled in the splitvallabels command through the -recode- option.

    Code:
    clear all
    sysuse auto
    splitvallabels foreign, length(8) local(vari) recode
    catplot , over(foreign, relabel(`vari')) percent
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	35.9 KB
ID:	1783924

    Comment


    • #3
      Thanks Andrew Musau

      A little big detail.

      Comment

      Working...
      X