How do I create a time plot in SAS? - sas

I am trying to create a scatter plot in SAS. I used the following code below;
proc sgplot data = data1;
series y = data_points x = Date;
run;
However the code creates a scatter plot where the data_points are linked together by a line.
I do not want the data_points to be linked together at all.
How do I solve this problem please?

SERIES -> draws a line plot
SCATTER -> draws a scatter plot
Change SERIES to SCATTER, that's the only change you need.

Related

How to create a bar chart with one x axis and two paralel y axes in PowerBI

I am new to PowerBI so sorry in advance. I would like to reproduce the plot below (created in Tableau) in PowerBI.
I need the two plots to be sorted by the values of the first one.
In PowerBI I can generate two such plots, but I do not manage to use the values of the first plot to sort the second one.
How can I do that?
Plot with an x-axis that is shared by two bar chart plots

Scatter plot columns without aggregation in Power BI Desktop

After reading this thread on the official forums I still didn't see how to plot columns without aggregation, and that thread did not offer any working solution.
Is there a way in MS Power BI Desktop to simply plot one or more columns without any aggregation?
Imagine I just have a simple table, imported from csv, that has numerical values in two columns, and I want to plot those individual values in a scatter plot, which is one of the most elementary tasks possible and is simply done e.g. in Excel.
Is this not possible in Power BI Desktop?
To my surprise, this was certainly not trivial...
The only solution / workaround I found so far feels hacky, and probably doesn't scale up for too many datapoints. But here it is nonetheless.
For simple, small, whole-number datasets...
Suppose this dataset:
X;Y
1;2
1;2
1;4
3;4
4;1
1;2
4;1
2;1
Import that CSV and add a calculated column:
Label = "(" & [X] & ";" & [Y] & ")"
Now create the scatter plot with:
Legend set to Label
X Axis set to Average of X
Y Axis set to Average of Y
And you'll get this:
Not optimal, but at least it's a start for smaller datasets.
For simple, small, fractional number datasets...
The same process as above, and it'll look like this:
The legend is starting to break down and is probably best removed.
For larger datasets...
Suppose you have an Excel sheet with two columns X and Y, both with the formula =RAND() * 5. Copy paste this row to e.g. 500 rows, so you have many data points.
Load it up in PowerBI. Add the Label column like above. Add a scatter plot and drag Label to Details, and set X and Y to their respective axis. Here's the result:
It works pretty decently, I guess.

how to plot Y*X with a specified x-axis in SAS

I'm trying to use proc gplot to create a plot of my y-variable against response, but have a specific covariate(z) on the x-axis. Is there a way to do this in gplot? Ive tried yxz, yx yz, and a bunch of other similar things but can't figure it out.
Thanks!
It sounds like a basic plot to me, I prefer PROC SGPLOT because its the easiest/clearest way to specify the X/Y. Assuming it's a scatter use SCATTER, if you want a line, use SERIES.
proc sgplot data=MY_DATA;
SCATTER X=TIME Y=PREDICTED_VAR;
RUN;

Vertical instead of horizontal numbers on x-axis proc univariate

I am drawing a normal histogram using the proc univariate procedure in sas:
proc univariate data=test;
histogram variabel;
run;
My question is simple. How do I make SAS write the text on the 1. axis in a vertical and not horizontal way?
I haven't been able to find a proper answer on the forum.
Thanks in advance.
If you are not using ODS Graphics, then this is fairly easy:
ods graphics off;
axis1 value=(angle=90);
proc univariate data=sashelp.class;
histogram age/haxis=axis1;
run;
This uses the axis options. These only apply to old-style graphics.
In ODS graphics, this is not really possible in a simple fashion. Fully, mandatory rotated axis labels are not possible until 9.4, and even then it is in GTL. You can use annotation to create your own axis labels, though, which is probably your best bet. Either way you wouldn't do it in PROC UNIVARIATE but in a PROC SGPLOT histogram.

SAS, ROC curve, PROC LOGISITC, point labels

I am trying to create a single ROC curve for three bio-markers on a common population.
I have already created an overlay curve from proc logistic statement. is there any way in SAS (among default options) to label the specific points on one of the bio-markers.
also, I would like to create a horizontal and vertical lines that depict the Sn and 1-Sp for those specific points.
is there an easier way to do this other than creating a annotation dataset and plotting a graph through proc gplot?
Thanks in advance!!
Among default options, the answer is no. SAS gives you options to control certain aspects of the ROC curves in the roc and rocoptions options in the proc logistic statement, but it doesn't support adding specific features to plots directly within the procedure.
To get the features you're looking for, as you said, you'll need to plot the raw ROC data using a graphics procedure. I like sgplot, the ODS graphics successor to gplot. Assuming you know exactly which points you want to label ahead of time, horizontal and vertical lines for the sensitivity and 1 - specificity can be generated using the refline statement in sgplot.
An annotation dataset may be the best way to go to label specific points. If you're using sgplot, you can generate an SG annotation dataset using the SG annotation macros. More information regarding SG annotation, including the use of the macros, can be found here. The macros are located in the default SAS autocall macro library so they should be able to be referenced without any special fussing. Once you have your dataset, you can feed it into sgplot using the sganno= option in the proc sgplot statement.