09-04-2024
sasheadache
Obsidian | Level 7
Member since
02-28-2023
- 20 Posts
- 7 Likes Given
- 0 Solutions
- 0 Likes Received
-
Latest posts by sasheadache
Subject Views Posted 1532 07-31-2024 03:45 AM 1653 06-19-2024 10:01 AM 1695 06-19-2024 08:33 AM 840 05-31-2024 03:24 AM 977 05-30-2024 09:52 AM 2246 02-21-2024 03:42 AM 2264 02-21-2024 03:01 AM 2274 02-21-2024 02:15 AM 2378 02-20-2024 10:20 AM 3404 02-16-2024 02:39 AM -
Activity Feed for sasheadache
- Posted PROC COMPARE Output mismatches on SAS Procedures. 07-31-2024 03:45 AM
- Posted Re: Using FINFO across a directory of files on SAS Studio. 06-19-2024 10:01 AM
- Posted Using FINFO across a directory of files on SAS Studio. 06-19-2024 08:33 AM
- Posted Re: Using Two-Dimentional Arrays to Transpose data on SAS Programming. 05-31-2024 03:24 AM
- Liked Re: Using Two-Dimentional Arrays to Transpose data for ballardw. 05-31-2024 03:24 AM
- Posted Using Two-Dimentional Arrays to Transpose data on SAS Programming. 05-30-2024 09:52 AM
- Liked Re: Dealing with payments / transactions and matching reversal entries for mkeintz. 02-26-2024 02:03 AM
- Liked Re: Dealing with payments / transactions and matching reversal entries for Ksharp. 02-26-2024 02:03 AM
- Posted Re: Dealing with payments / transactions and matching reversal entries on SAS Programming. 02-21-2024 03:42 AM
- Liked Re: Dealing with payments / transactions and matching reversal entries for mkeintz. 02-21-2024 03:02 AM
- Posted Re: Dealing with payments / transactions and matching reversal entries on SAS Programming. 02-21-2024 03:01 AM
- Posted Re: Dealing with payments / transactions and matching reversal entries on SAS Programming. 02-21-2024 02:15 AM
- Posted Dealing with payments / transactions and matching reversal entries on SAS Programming. 02-20-2024 10:20 AM
- Posted Re: Find the min and max date values across multiple date variables using Array on SAS Procedures. 02-16-2024 02:39 AM
- Liked Re: Find the min and max date values across multiple date variables using Array for Tom. 02-15-2024 09:16 AM
- Liked Re: Find the min and max date values across multiple date variables using Array for Tom. 02-15-2024 09:15 AM
- Posted Re: Find the min and max date values across multiple date variables using Array on SAS Procedures. 02-15-2024 04:18 AM
- Posted Re: Find the min and max date values across multiple date variables using Array on SAS Procedures. 02-14-2024 09:14 AM
- Posted Find the min and max date values across multiple date variables using Array on SAS Procedures. 02-14-2024 08:34 AM
- Posted Re: ODS Excel - proc print columns widths on SAS Programming. 12-07-2023 10:24 AM
-
Posts I Liked
Subject Likes Author Latest Post 1 1 2 1 1
07-31-2024
03:45 AM
I have done a proc compare across 2 datasets. Can anyone advise if there is a method to output the 58 cases from Observation Summary onto an dataset?
... View more
06-19-2024
10:01 AM
Hi Bart, That's my main problem, neither the dirid or numfiles are being populated but I just don't understand why. (refer additional log snippet below). I also already tried moving the filename statement outside of the datastep, changed the folder path from single to double quotes etc but didn't have any luck.
NOTE: Argument 1 to function DNUM(0) at line 94 column 11 is invalid.
ERROR: Invalid DO loop control information, either the INITIAL or TO expression is missing or the BY expression is missing, zero,
or invalid.
dirid=0 numfiles=. i=0 filename= file= sysrc=. fid=. bytes= moddate= crdate= rc=. _ERROR_=1 _N_=1
In terms of the package I dont think we have it, but I have asked our SAS team if they can check.
... View more
06-19-2024
08:33 AM
I am trying to run down a list of files in a directory on SAS Studio to find the size and last modified date of each file. The code below was taken from another site and simply adapted to my folder locations but I cannot get it to work. (Original solution linked at the bottom)
I am getting the below error, which I believe is because it isn't evaluating the 'dirid' and 'numfields' correctly before the DO statement. But then I don't know why... Can anyone help?
"ERROR: Invalid DO loop control information, either the INITIAL or TO expression is missing or the BY expression is missing, zero, or invalid."
data info (keep=filename bytes crdate moddate);
/* Assign the fileref 'files' to the directory location*/
filename files"/USER/01_folder";
/* Opens up the directory, dirid is now the directory id*/
dirid=dopen('files');
/* Counts the number of files in the directory*/
numfiles=dnum(dirid);
/*Loop each file */
do i = 1 to numfiles;
/* Identify the file as filename */
filename=dread(dirid,i);
/* Find the file in the location */
file="/USER/01_folder/"||Filename;
/* Assign the fileref 'fnames' to this file */
sysrc=filename('fnames',file);
/* Open the File*/
fid=fopen('fileref');
/*If the file is opened */
if fid ^= 0 then do;
bytes=finfo(fid,'File Size (bytes)');
moddate=finfo(fid,'Last Modified');
output;
/*Close the file */
sysrc=fclose(fid);
end;
end;
/*Close the directory */
rc=dclose(dirid);
run; https://katalyzedata.com/tips-tricks/getting-the-finfo-from-your-files/
... View more
05-31-2024
03:24 AM
Thanks! (Turns out I could have used proc transpose in the way I initially wanted before I ventured into Array's)
... View more
05-30-2024
09:52 AM
I have a dataset that I am trying to use a multi-dimensional array to transpose the data from 2 variables, however I am having issues because the array not only needs to be dynamic, but also allow me to group certain records together using multiple variables.
This is my source table:
id
action_date
status
status_date
1
01/01/2024
A
01/01/2024
1
01/01/2024
A
02/01/2024
1
01/01/2024
B
03/01/2024
1
01/01/2024
C
04/01/2024
1
01/01/2024
D
05/01/2024
2
01/01/2024
A
01/01/2024
2
01/01/2024
A
02/01/2024
2
01/01/2024
A
03/01/2024
2
01/01/2024
A
04/01/2024
2
01/01/2024
A
05/01/2024
1
25/01/2024
A
25/01/2024
1
25/01/2024
A
26/01/2024
1
25/01/2024
A
27/01/2024
1
25/01/2024
A
28/01/2024
1
25/01/2024
A
29/01/2024
55
26/01/2024
A
26/01/2024
55
26/01/2024
D
27/01/2024
55
26/01/2024
D
28/01/2024
As you will see:
ID1 has 10 rows with 2 x different action_dates
ID2 has 5 rows with 1 x action date
ID55 only has 3 rows all with the same action date.
* Note: status and status_date are the variables I want to transpose into adjacent columns (i.e. status1, status_date1, status2, status_date2, status3, status_date3 etc.)
* Note: The same ID can appear more than once - I want these to be treated independently, grouping by the action_date for that ID.
* Note: Some ID's dont always have 5 rows which is why I need the array to be dynamic to ensure the output is consistent. (As displayed in the example below - if the ID only has 3 rows out of the maximum 5 I want it to populate the first 3 columns and leave the last 2 blank.)
This is my desired output:
id
action_date
status1
status_date1
status2
status_date2
status3
status_date3
status4
status_date4
status5
status_date5
1
01/01/2024
A
01/01/2024
A
02/01/2024
B
03/01/2024
C
04/01/2024
D
05/01/2024
2
01/01/2024
A
01/01/2024
A
02/01/2024
A
03/01/2024
A
04/01/2024
A
05/01/2024
1
25/01/2024
A
25/01/2024
A
26/01/2024
A
27/01/2024
A
28/01/2024
A
28/01/2024
55
26/01/2024
A
26/01/2024
D
27/01/2024
D
28/01/2024
This is my starting array code.
data output;
set input;
array status[5] $2. status_1-status_5;
array status_day[5] status_day_1-status_day_5;
format status_day_1-status_day_5 date9.;
do i = 1 to 5;
status[i] = status;
status_day[i] = status_day;
end;
run;
... View more
02-21-2024
03:42 AM
Reversals will never be combined - so in theory the values will always match i.e. Credit £100 & Debit £100.
The main problem is other debits and credits can appear in-between which are not cancelled out. (These are what I want to retain as I am classifying these as true payments)
If you think of how your day to day banking works.... You might buy something today, but then return it and get a refund in 30 days time. I am wanting to drop both transactions from my list, but without a true reference to link them together. (annoying I know)
... View more
02-21-2024
03:01 AM
Transaction Ref Transaction Date Account Ref C/D Transaction Amt Ref 3 14/02/2024 Account A CREDIT 50 Ref 5 16/02/2024 Account A CREDIT 50 Ref 6 21/02/2024 Account A CREDIT 100 As you will see transactions 1,2, 4,7 have been dropped because they have cancelled each other out.
... View more
02-21-2024
02:15 AM
Apologies for the typo - the notes should show reversals for transactions dated 01/02 & 07/02 and not January.
... View more
02-20-2024
10:20 AM
Hi All, I don't think there is a 100% accurate solution here because of the rubbish data I have, so just looking to see if others have come up with any innovative solutions. Essentially, I have a table which includes both debit & credit transactions and where a payment has been reversed at some point I need to drop both entries from the final output. The problem I have is there is no way to directly link the debit & credit transactions together. Whilst the amounts will be the same (i.e. +£100 & -£100) they don't always appear on either the same date or on consecutive date for me to be able to group them together and then drop them. This is an example of how the table is structured and as you will see.... Ref: 001 is cancelled out by Ref: 004 and Ref: 002 is cancelled out by Ref: 007. Transaction Ref Transaction Date Account Ref C/D Transaction Amt *Notes (not in table) Ref 1 01/02/2024 Account A CREDIT 100 Ref 2 07/02/2024 Account A CREDIT 100 Ref 3 14/02/2024 Account A CREDIT 50 Ref 4 15/02/2024 Account A DEBIT 100 *reversal of 01/01/2024 Ref 5 16/02/2024 Account A CREDIT 50 Ref 6 21/02/2024 Account A CREDIT 100 Ref 7 23/02/2024 Account A DEBIT 100 *reversal of 07/01/2024 Welcome any expert views/thoughts.
... View more
02-16-2024
02:39 AM
Thanks Tom! Really appreciate your time
... View more
02-15-2024
04:18 AM
Thanks! On the off chance, do you know if there is a way to use datepart() in either the proc summary/means or transpose? Typically I have a couple of variables which contain datetime and wanted to save another processing step if I could. (I tried setting additional format lines for the impacted fields to the proc transpose but that just overrides everything.) Appreciate the support!
... View more
02-14-2024
09:14 AM
The 'Results' is exactly the view I wanted to see (I just need to re-format the mix/max columns to show as a date). The 'Output data' however has transposed the data in the opposite way i.e. variables are in columns and min max in rows. I ideally wanted output table to match the 'Results' output.... do you know if there is a simple way to force the output to show the same view? Or will I need to do some further steps to recreate this view i.e. 1. drop the _TYPE_ _FREQ_ columns 2. retain where _STAT_ in ('MIN ' MAX') 3. transpose the data Thanks
... View more
02-14-2024
08:34 AM
Hi All, I have a dataset which contains a list of date variables (in columns) and I need to return the min() and max() values for each one. I have used the below code to get all date variables from my source table, to then pass them into a macro variable to ensure the field list stays dynamic. /* OBTAIN FIELD LIST */ proc contents data=test out=field_list; run; /* PASS DATE FORMATTED COLUMNS INTO MACRO TOKEN */ PROC SQL; SELECT NAME INTO:DATE_FIELDS separated by ' ' FROM field_list WHERE FORMAT = "DATE"; QUIT; I was then hoping to use the &field_list in an array find the min and max value for each, can anyone assist please? Desired Array Output: MIN MAX Var1 01-Jan-00 30-Jan-24 Var2 etc. etc. Var3 etc. etc. Var4 etc. etc. Var5 etc. etc.
... View more
12-07-2023
10:24 AM
So I don't have the ability to simply use 'ods excel' because it produces excel files which are full of nonsense i.e. special characters & symbols (guessing its a SAS config issue at my company). But the good news is I have now managed to replace the same steps using my current method of output using 'ods tagsets.excelbase'. I didn't realise until now how many different variations there were with outputting and formatting data to Excel, so that should keep me busy upskilling for a few weeks. 🙂 Thanks for taking the time to reply - all the best!
... View more
12-07-2023
02:24 AM
The full code extract was on the original post - included now for reference. In my adapted version of this code the only difference is the fact I am using 'ods tagsets.excelbase' instead of 'ods excel' from the original post. /* 1) proc contents to recover the length of each variables */
proc contents data = table_you_want_export
out = other_name (keep = varnum length) noprint ;
run ;
/* sorting by varnum to have the same order that the table you want export */
proc sort data = other_name ;
by varnum ;
run ;
/* creating a macro variable containing these lengths separated by a comma */
proc sql noprint ;
select length into : length_var separated by ','
from other_name ;
quit ;
/* EXPORT */
ods excel file="path\name_output.xlsx"
options(
flow = "header, data"
absolute_column_width = "&length_var"
absolute_row_height = "20px"
);
Proc print data = table_you_want_export noobs ;
run ;
ods excel close ; The value of the macro variable resolves to: 83 %put &length_var.; SYMBOLGEN: Macro variable LENGTH_VAR resolves to 8,11,14,125,8,8,8,8,8,11,125,14,14,14 8,11,14,125,8,8,8,8,8,11,125,14,14,14 The first value in the macro variable is 8 and the proc print is then applying this length to all columns. Thanks
... View more