calculating time periods between specific data entries

The following data is given and sorted by id and date. I would like to find out how many days lie between data entries of class A and of B within an id creating a new variable called ‘days_diff’. The goal is to be able to calculate if the difference in days exceeds a predefined… Read More calculating time periods between specific data entries

How to extract some value from character column in PROC SQL in SAS Enterprise Guide?

I have table in SAS like below: data type: ID – numeric TYPE – character ID TYPE 111 {"Top":10} 222 {"abC":"false","Top":111, "aa":5} 333 {"Top":15.2} … … And I need to create new column "COL1" base on column "TYPE" where I need to extract value which is after character "Top": So I need something like below:… Read More How to extract some value from character column in PROC SQL in SAS Enterprise Guide?

How is my SQL subquery evaluating to more than one row? When run independently, it works fine, but doesn't work in a SELECT subquery

I am obtaining values from two tables. When I run the subquery in its own PROC SQL statement in SAS, it runs fine, with the count of citations for each ID. When I input the subquery into my SELECT outer query, it gives me ERROR: Subquery evaluated to more than one row. I am having… Read More How is my SQL subquery evaluating to more than one row? When run independently, it works fine, but doesn't work in a SELECT subquery

Sas to Postgres Migration

I need to change sas code into PostgreSQL. But I couldn’t understand this code. Please help me to translate following code into SQL code. data fc_action_v1; set action_targets; Region_mod = upcase(region); rename ‘2nd_Item_nr’n = Prodnumber; run; Is this above sas code equivalent to following sql code? create table data fc_action_v1 as select region_mod as region,… Read More Sas to Postgres Migration

SAS – Can I create a table of all table names within a library and then all variables within those tables?

I would like to create a new table with all tables contained within a library and the variables within each of those tables. I know I can use something like the below to get the table name but I cant find much on getting each variable. I have multiple libraries and each has potentially hundreds… Read More SAS – Can I create a table of all table names within a library and then all variables within those tables?

How can I output a certain number of observations satisfying a where statement in SAS

For example I want to output only the first 5 observations in the table CARS which satisfies the WHERE statement that Horsepower is greater than 265. DATA test(obs=5); SET SASHELP.CARS; WHERE Horsepower > 265; RUN; The above doesn’t work. This seems very simple but I’m not sure how to achieve what I want here. >Solution… Read More How can I output a certain number of observations satisfying a where statement in SAS