I have Table in SAS Enterprise Guide like below: Data type: ID – numeric SERVICE – character ID SERVICE 123 P1 123 P1 123 G 444 AB 56 c2 And I need to know how many time each ID bought each SERVICE, so as a result I need something like below: Because for example ID = 123 bought SERVICE =
Tag: proc-sql
How to create flag 0/1 inform whether was changed or not during 4 months between two columns in PROC SQL in SAS Enterprise Guide?
I have table in SAS Enterprise Guide like below: name of table: table123 date typ: ID – numeric DT – numeric VAL1 – string VAL2 – string ID DT VAL1 VAL2 123 20210523 PR P 123 20211222 P P 222 20210502 PR M 222 20210711 M PR 38 20210513 PR PR 991 20211123 M P And I need to create
Selecting the maximum date before a certain year
I have a table where I’d like to select only the record with the maximum date: The issue is that I have some IDs in the table where the maximum date is in 2022, so that is what gets selected. How do I select the maximum date for a record that is before 01JAN2022 so that my output look like
Case Statement and Aggregation within a Group By classe in proc sql
I am having some trouble aggregating and using case within a group. The objective is to check Indicator for each transaction key. If ‘1’ indicator exists then we have to select the max(Change_Date). …
SAS-Append data to a table and increment a flag on the resultant table
I have two tables on SAS “Table_A” and “Table_A_Archive”, as part my ETL process “Table_A” is created on a daily basis and the data should be archived on “Table_A_Archive”. When the data is archived on “Table_A_Archive” a a flag will be created/updated “DT_FLAG”. On the first day this is how the table would look like On Day 2 The new
SAS datastep/SQL select latest record from multiple records with same ID
For example I have a dataset as below: By datastep or sql, how could I get the record with id = 1 and latest Date 2002/01/01? Help is appreciated and thanks in advance. Answer Try this sql.