In SAS graph, I have a graph that expresses axis2 with dates(Batch_date) from 6/24/2015 to 12/8/2015 in 6 day increments. If I use the statement -
proc gplot data=datasets.x_batch;
plot
prcnt_10*batch_date=1
prcnt_20*batch_date=2
prcnt_30*batch_date=3
prcnt_40*batch_date=4
prcnt_50*batch_date=5
prcnt_60*batch_date=6
prcnt_70*batch_date=7
prcnt_80*batch_date=8
prcnt_90*batch_date=9
prcnt_100*batch_date=10
prcnt_110*batch_date=11
prcnt_120*batch_date=12....
It creates my plot successfully, but the tick marks seem to be notated with default values (6/16,7/1...etc). I understand how to control the tick marks with the minor=(n=n h=n) and major=(h=n) but it still chooses different values to display on the major tick marks.
Is there a way to explicitly assign each tick mark label (or better yet, just call out the date variable values for the tick mark labels) with out explicitely stating each date value in an (order) statement?
Related
EDIT: the issue with this question was resolved as Stata changed the variable names in Excel to variable "labels" upon importing the data, and generated the variable "names" that I needed automatically. So the question is unnecessary.
I have a dataset in Stata that has a handful of variable names, some of which begin with a number and a period. Like so:
name of car 62. color of car 145. year of sale state of sale
Accord Red 1995 GA
Corvette Pink 2010 FL
...
How can I remove the numbers from the variable names that contain them so that I wind up with:
name of car color of car year of sale state of sale
Accord Red 1995 GA
Corvette Pink 2010 FL
...
I have some familiarity with the substr() function, but I am confused by the fact that the character count that I need to remove from is not consistent. Instead, I need to remove everything from the period following the number, back.
All those "names" are illegal as variable names, because Stata variable names just can't include spaces or periods or start with a number.
So either your Stata is corrupted beyond belief or you're misunderstanding what you have.
My best guess is that you have read in metadata so that text that could and should be variable labels is in fact making up the first observation (row) in your dataset. If so, the best advice is to go back and repeat the import so that metadata is not read into the dataset. The commands concerned have options to choose that.
In any case, it is immensely better to show data examples using dataex: see the tag wiki for Stata.
I am working on a report that displays monthly data most of which are represented in the following format, XX+YY (IE 01+11,02+10,03+09, etc.). The first set of digits reflect the represented month, so these naturally order themselves in sequence.
Image of visual with correct sequence
However, I must also include the financial plan for the year is in the format "FYXX Plan" where XX is the last two digits of the calendar year. When sorting text Power BI orders leading numbers before leading letters, so this moves the plan column to the END of the data set instead of where it logically belongs at the FRONT.
Image of visual with incorrect sequence
Is it possible to re-order my visual to still show the XX+YY monthly data in ascending order, but to move the FYXX Plan data to be the first column shown?
Very respectfully,
Jon J.
You could add a new column for sorting, stripping out the 'FY' when it exists e.g.
SortColumn = IFERROR(mid(Sorting[Date],find("FY",Sorting[Date])+2,10),Sorting[Date])
(For any value which includes 'FY' the mid function will show the remaining characters, if FY is not found it will error, and give the full date, there are a number of ways to achieve this using e.g. IF statements etc.
You can either replace the axis with this column, if you really need it to display as 'FYxx' you could set First(SortColumn) as the tooltip text to allow you to sort by that instead.
I have a scatter chart and a db view to get the necessary data from it. This view only returns the names and its's respective values and is enough to make my chart just fine. Problem is that i want to draw a Constant Line on my chart but i want to read its value from a configuration table that i have in my DB. Currently when i try to add the Y-axis constant line in power bi, it only allows me to type the static value and it won't get the data dynamically from somewhere else; a different key-value based table that i already mentioned above. How can i achieve this?
Here's the images:
Thanks in advance.
There is not direct solution for this problem but this workaround did the job for me:
Create a measure (may work with a calculated column that will later be summarized as average, MAX, MIN, etc.). The measure (or aggregation of calculated column) will have the dynamic value of the constant line you want to display. In my case, I used a measure and I am showing a constant line that changes value depending on the current month.
Create your visual without the constant line first. In my case, I am using the clustered bar chart.
Add the measure with the constant value to your list of values of the visual. The value will appear in your visual. In my case, it appeared as another horizontal bar. You'll hide it in a later step.
Go to the analytics tab of the visual and instead of adding a new Constant Line, add a Min Line, Max Line, or whatever line makes more sense for your measure, column, visual, etc. as long as the option you choose allows you to select the measure/column you added in the previous step. From the formatting options of the line you added, click on the dropdown labeled "Measure" and pick the measure that has the value of the constant line.
Finish formatting the line as you want (title, text position, color, etc.).
Go back to the Fields tab of the visual and drag the measure with the constant value from the Value group to the Tooltips group. The value will now disappear from the visual but the constant line should remain.
(optional) If you do not want the value of the now dynamic constant line to show in the Tooltip of the visual, create a custom visual. However, keep in mind that if the user is viewing the report in a way that doesn't support report page tooltips, the user will see the default Tooltip including the value of the dynamic constant line you just created.
I am trying to plot SAS line plot with X- axis as Hour ( 0 , 1, 2...24) and Y axis is Decline Rate.
I started my monitoring at Hour = 20 (8PM) . I need to plot the line plot starting with 20.
When it goes to 0 , the line joins o to 20 forming a straight line.
How can i handle this in SAS. I am using PROC GPLOT
This is a difficulty for SAS, but one that can be managed.
I have two solutions:
Solution 1)
Keep the hour as a column in the data, but also add a date/time field to denote that the time is always increasing.
Use the date/time field and Decline Rate within gplot, but format the date/time field to only show hours.
Solution 2)
Add a new column to denote the order
data temp;
set temp;
order = _n_;
run;
Then sort by the new variable.
proc sort data=temp; by order; run;
Finally, utilize the sorted option within gplot. See the attached link for further information: http://www.math.wpi.edu/saspdf/gref/c21.pdf
This might be a weird question. I have a data set contains data like agree, neutral, disagree...for many questions. There is not so many observations so for some question, one or more options has frequency of 0, say neutral. When I run proc freq, since neutral shows up in that variable, the table does not contain a row for neutral. I end up with tables with different number of rows. I would like to know if there is a option to show these 0 frequency rows. I will also need to run proc gchart for the same data set, and I will run into the same problem for having different number of bars. Please help me on this. Thank you!
This depends on how exactly you are running your PROC FREQ. It has the sparse option, which tells it to create a value for every logical cell on the table when creating an output dataset; normally, while you would have a cell with a missing value (or zero) in a crosstab, if that is output to a dataset (which is vertical, ie each combination of x and y axis value are placed in one row) those rows are left off. Sparse makes sure that doesn't happen; and in a larger (n-dimensional) crosstab, it creates rows for every possible combination of every variable, even ones that don't occur in the data.
However, if you're just doing
proc freq data=mydata;
tables myvar;
run;
That won't help you, as SAS doesn't really have anything to go on to figure out what should be there.
For that, you have to use a class variable procedure. Proc Tabulate is one of such procedures, and is similar to Proc Freq in its syntax (sort of). You need to either use CLASSDATA on the proc statement, or PRINTMISS on the table statement. In the former case, you do not need to use a format, I don't believe. In the latter case (PRINTMISS), you need to create a format for your variable (if you don't already have one) that contains all levels of the data that you want to display (even if it's just an identity format, e.g. formatting character strings to identical character strings), and specify PRELOADFMT on the proc statement. See this man page for more details.