Hi, I am trying to convert a six-digit number or string to a date with yyyymm format, then create two (or potentially) more new date variables, one is 12 months prior to that date, and another is 24 months prior to that date. Below is the example. Let's say I have a pre-define date in yyyymm format (i.e 202312 for December 2023), I want to 1) convert this 202312 to a date. Since at this time I am not 100% sure if data will flow in from upstream process as a string or a numeric value, I tried to convert to both numeric and character (using input and put function, respectively) 2) create two more new fields. dt12 is 12 months prior to 202312, which would be 202301. dt24 is 24 months prior to 202312, which would be 202201 3) these new fields will be used as a filter in the where statement to extract subset of data within specific time period. I was not able to create dt12 and dt24, any advice or guidance will be greatly appreciated. %let yyyymm_character='202312';
%let yyyymm_numeric=202312;
data test;
dt_numeric = input(&yyyymm_numeric,YYMMNw.);
dt_character = put(&yyyymm_numeric,YYMMNw.);
dt12 = intnx('month',dt_numeric,-12,'e');
dt24 = intnx('month',dt_numeric,-24,'e');
run;
... View more
Hey SAS-C,
Just FYI.
Bart
SAS Packages Framework, version 20240529
Available as usual at: https://github.com/yabwon/SAS_PACKAGES
Changes
aesthetic changes in log when running %generatePackage() macro,
reshaped format of an automatic documentation header,
and little bug fix for automatic documentation generation (in code for excluding files from documentation the IN operator should be used instead IN: ).
Packages
BasePlus, version 1.39.0
Changes:
new parameter DSout= added in %downloadFilesTo() macro,
file SHA256: F*3C3A2050E3FF46E1FC0F936634A66FC3F294A3531EFE0A7DC9CE74F2EF17C687 for this version.
... View more
I have the following data, How I can create the multiple records based on the horizontal data , depening on the time variables. thank you for your help.
Assumptions:
1. if all four time vairables avaialble then need two records with startdate time and stopdate time depending the on the time
Example first and second rows. only difference between first and second row is column D and E have same time
2. when "restarttime" missing consider the "intermediatestopTime as "restarttime"( and vice versa) and create two records.
3. when "intermediatestoptime" and "restartime" missing then create one record for "stopdatetime" and "startdatetime".
data have;
format date date9. starttime time8. intermediatestoptime time8. restarttime time8. finalstoptime time8.;
do i = 1 to 4;
usubjid = "00-01";
date = '01OCT2024'd;
/* Generate different times for each record */
starttime = '12:20:00't + (i-1)*600; /* Increment start time by 10 minutes each iteration */
intermediatestoptime = starttime + 600; /* Intermediate stop time is 10 minutes after start time */
restarttime = intermediatestoptime + 600; /* Restart time is 10 minutes after intermediate stop time */
finalstoptime = restarttime + 600; /* Final stop time is 10 minutes after restart time */
output;
end;
drop i;
run;
data have1;
set have;
if _n_ =2 then restarttime = '12:40:00't;
if _n_ =3 then restarttime = '';
if _n_ =4 then do; restarttime = '';intermediatestoptime='';end;
run;
... View more
Hi, I am new to SAS. I want to create a geo-map displaying frequency of occurrences of something. but it should be able to access countries, states and cities in the map. I tried with geo-hierarchy. But after creating the geo map, it was not drillable to states and cities. Only displaying country info on the map. Help me if you know how to do this. Appreciate your help.
... View more
Obs months 1 2 2 2 3 6 4 2 I want to merge the dataset above with other datasets based on value of months variable. For example, I want to merge two months of data for the first record, two months of data for the second record, 6 months of data for the third record, and 2 months of records for the fourth record. Is there a systematic way of doing it? I was thinking about creating a variable based on the months variable and create a loop within a macro to achieve it.
... View more