BookmarkSubscribeRSS Feed
AndreaLovdel
Calcite | Level 5

Hi all,

 

I can't code, so I am relying on the Task tool to graph my data which is working great so far. However my dataset is quite large, and I have different information about subjects such as their weight, height, temperature, blood pressure etc. I want to graph these in different graphs which I have managed fine too. However, I want each graph for each variable to have the specific y-axis unit, for ex for the temperature graph I want 'Celsius' on the y-axis, and for height to be 'cm' etc. I have one column with the data set, and another column with the 'original units'. Is there a way of customising the code the Task tool for line plot to add this in automatically? 

 

An ex that have that works for the title is the #byval(SubjectID), where I can put the code in the title, and then each graph will have the specific title based on the subject ID. I’ve tried to add the same byval function in the y-axis title #byval=(ColumnWithUnit) but it just displays the function.

 

I was advised to potentially create a macro variable for this, but again I don't know where to start with this, and where to insert it etc. 

 

When I use the Task tool to create a graph, in the settings, I get the option to customise the code that SAS EG creates for me as I change the properties of the graph. Is there any code that I can add there somewhere to make this work?

 

Thank you very much 🙂

Andrea 

1 REPLY 1
TomKari
Onyx | Level 15

I'm not 100% sure that I understand what you're after, but this might give you some ideas.

 

First, let's assume you're working with the "SASHELP.CARS" dataset. Among others, it has "Stores", "Sales", "Inventory", and "Returns" variables.

 

To emulate your dataset that contains the unit values for the different variables, I'm submitting this code:

 

data concurrence;
	length VarName $20 UnitName $20;
	input VarName UnitName;
	call symput(strip(varname), strip(UnitName));
	cards;
Stores Integer
Sales DollarsS
Inventory DollarsI
Returns DollarsR
run;

This will put values like "Integer" into macro variables like "Stores".

 

Now when you create your chart, on the Vertical Axis / Label text box, put your variable name preceeded by a & and followed by a dot. So if you're variable is "Sales", you would type "&Sales." (no double quotes!), and you would see DollarsS as the axis label.

 

Does this move you towards where you want to be?

 

Tom

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 721 views
  • 0 likes
  • 2 in conversation