Getting records in the last 1 hour using PROC SQL (Teradata) - sas

I am using SAS to connect to Teradata. Given the below dataset (it's a transaction table that updates records regularly), I need to be able to select records from the past hour (at least 3). So for example, if I am running the query at 6pm, I should get txn_id 5678, 1985, 2985 (refer to below dataset). Can you please help? This needs to be done in proc sql (connecting to teradata) or even just a SQL query running in Teradata SQL Assistant.
Dataset:
TXN_ID Date Time
1234 20200608 4:00 PM
5678 20200608 5:00 PM
1985 20200608 5:30 PM
2985 20200608 5:45 PM
2365 20200608 2:30 PM
Expected Output:
TXN_ID Date Time
5678 20200608 5:00 PM
1985 20200608 5:30 PM
2985 20200608 5:45 PM

Try outobs option :
proc sql outobs=3;
select * from sashelp.class order by Age, Name;
quit;
This option is used to limit the number of rows in the output.

Related

First steps to detailed report in power BI

I have some experience in SSRS, but new in Power BI.
Would you prompt me please the first step create a detailed report in Power BI.
Initial dataset:
Client Country Month
John USA jan
Ivan Russia feb
Albert England mar
... ... ...
Desirable result:
The matrix with aggregations on the top of the Page:
Clients jan feb mar
England 50 5 30
USA 75 7 15
Russia 25 5 15
By clicking on the numbers, I want to get filtered information about clients on the bottom of the Page (e.g. if we click on 50, we get 50 rows with clients from England in January):
Client Country Month
Mary England jan
Mick England jan
Albert England jan
... ... ...
This can be done by creating 2 linked objects in Power BI: the matrix and the table.
Matrix:
Rows = Country
Columns = Month
Values = Count of ClientS
Table:
Values = Country, Month, Clients

Powerbi DAX formula for calc previously date

i have data set from my Azure DevOps (collect data with work items, state, date etc...) and i want calculate count of work item from previously date. It's necessary what calculate grown rate (current count of work items - count of work items from previously date) and create visualisation.
Data set format (example):
field# (1) work item id (2)Date) ...
Graph Example (as is):
Graph Example (to be):
Example of raw data:
Can I consider these below you sample raw data? I will delete this answer after everything is clear.
date work item id
9/24/2020 1012
9/24/2020 1013
9/24/2020 1014
9/25/2020 1012
9/25/2020 1013
9/25/2020 1014
9/25/2020 1015
Gap in date
9/27/2020 1012
9/27/2020 1013
9/27/2020 1014
9/27/2020 1015
9/27/2020 1016
9/27/2020 1017
If I consider Date wise ID count, below is the result-
date id count
9/24/2020 3
9/25/2020 4
9/27/2020 6
Now what you want from the above counts? As per my understanding-
date diff
9/24/2020 3 ->> As no previous date available, its current date count
9/25/2020 1 ->> Diff between current and previous date
9/27/2020 ? ->> what you wants here? as previous date is not there

How to generate_series of every hour of every day of 1 year from the current timestamp

I have a query that generates every day of the year(shown below). What if I want to get a series of every hour of every day of the year from the current timestamp. Example: today is July 23,2019 10:30:00 AM, the result I am hoping to get is below
2019-07-23 20:30:00
2019-07-23 20:00:00
2019-07-23 19:00:00
2019-07-23 18:00:00
.
.
.
2018-07-23 20:00:00
This is a Redshift (PostgreSQL 8.0.2) query for Eclipse Birt. Hoping to create a parameter for both date and time but seems difficult to achieve if 2 separate ranges.
select cast(convert_timezone('UTC','AEST',cast(now() as timestamp without time zone)) as date) - generate_series(0, 365) date,
to_char(cast(convert_timezone('UTC','AEST',cast(now() as timestamp without time zone)) as date) - generate_series(0, 365), 'dd/mm/yyyy') date_disp;
Example: today is July 23,2019 10:30:00 AM, the result I am hoping to get is below:
2019-07-23 20:30:00
2019-07-23 20:00:00
2019-07-23 19:00:00
2019-07-23 18:00:00
.
.
.
2018-07-23 20:00:00
This is to similar to your previous question.
Use:
SELECT date_trunc('hour', now()::timestamp) - generate_series(0, 24 * 365) * interval '1 hour'
This outputs:
2019-07-23 05:00:00
2019-07-23 04:00:00
etc
You can use the DATEADD Redshift function, using "h", "hr" or "hrs" as your first parameter. Documentation for this function can be found here and here.

Calculate Variance in PowerBI using dax query

I am trying to create a variance measure in PowerBI.
This is the data that I have,
Month Year MonthNo Value
Jan 2016 1 700
Feb 2016 2 800
March 2016 3 900
April 2016 4 750
.
.
Jan 2017 13 690
Feb 2017 14 730
And My variance for the Month Number 7 should be like,
`{Avg(values(4,5,6) - Value(7)} / Value(7)`
i.e (Average of last 3 months value - current month value) / Current month value
How to do this in Power BI? Thanks.
If it is okay for you to use a column, I believe you could add one with this code to get what you want:
Variance = (CALCULATE(AVERAGEX(Sheet1,Sheet1[Value]),FILTER(FILTER(Sheet1,Sheet1[MonthNo]<=EARLIER(Sheet1[MonthNo])-1),Sheet1[MonthNo]>=EARLIER(Sheet1[MonthNo])-3))-Sheet1[Value])/Sheet1[Value]
You'll need to replace all instances of Sheet1 with the name of your table.
It'll give you something like this:

Which Informat Reads this time hh:mm:ss PM Or AM in SaS?

I can't Read a column from excel which like
9:32:18 AM
9:32:23 AM
9:34:31 AM
9:34:33 AM
4:53:56 PM
8:28:44 AM
8:35:19 AM
4:21:22 PM
8:37:50 AM
8:37:58 AM
8:38:16 AM
4:44:33 PM
in SAS Base 9.4 on Windows 10
TimeZone +2