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

Hello, I am new to SAS so any information will be greatly appreciated. Thank you in advance!

I am trying to make a graph to represent some survey responses to 15 Likert-scale answers. 

Here is an example of what my data looks like:

mcmaxwell_0-1611359384901.png

I would like to make a graph very similar to the one below. (retrieved from: https://blogs.sas.com/content/graphicallyspeaking/2014/10/30/likert-graphs/#prettyPhoto).

Likert_Panel_4.png

The main differences are (1) that I am not grouping my responses in any way (so each panel would only have one horizontal bar) and (2) I used a 7 point Likert-scale (so each horizontal bar would have 7 sections on my graph).

 

Here is the example code from the website: 

ods listing style=styles.likert;
title 'Survey Responses to Questions by Country';
proc sgpanel data=Likert_4 ;
  panelby question / layout=panel columns=1 onepanel novarname noborder nowall;
  highlow y=country low=low high=high / group=group type=bar nooutline   
          lowlabel=sumdisagree highlabel=sumagree;
  rowaxis display=(nolabel noticks) fitpolicy=none;
  colaxis display=(nolabel noticks novalues);
  keylegend / noborder;
run;

I have tried modifying this code a few different ways but have not had any luck. Any suggestions would be greatly appreciated! I believe I need to make several variables (i.e. "highlow", "low", "high", etc) but I am not sure how to do that. I also do not have a y variable, and I am not sure if this code will work without one. Is there a simpler way to make this graph? Again, thank you in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

First thing is read the whole article and pay special attention to the bit where Sanjay says:

My data is sorted by the Qid, Country and Group. I can process the data and compute Low and High values for each group, starting with zero. You can see the data step in the full program attached below.

And then get the Data step he links with the label: Full SAS Code

You need to make your data look similar to the result of his data step that fakes the data (fake because he is creating values with random number function ranuni). The important part the variables and structure must be similar.

 

General approach: You need to add a variable to take the place of Country that has a single value per question and use that where Sanjay uses Country and use the data step code to create the variables that he actually used in the Proc SGPanel code.

 

 

 

 

 

View solution in original post

1 REPLY 1
ballardw
Super User

First thing is read the whole article and pay special attention to the bit where Sanjay says:

My data is sorted by the Qid, Country and Group. I can process the data and compute Low and High values for each group, starting with zero. You can see the data step in the full program attached below.

And then get the Data step he links with the label: Full SAS Code

You need to make your data look similar to the result of his data step that fakes the data (fake because he is creating values with random number function ranuni). The important part the variables and structure must be similar.

 

General approach: You need to add a variable to take the place of Country that has a single value per question and use that where Sanjay uses Country and use the data step code to create the variables that he actually used in the Proc SGPanel code.

 

 

 

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 834 views
  • 0 likes
  • 2 in conversation