Hello! I have a question. Soon I will work with some data that are located on a shared fold in the google drive. This dataset is a STATA dataset. How can I import a STATA dataset that is located in google drive? Thank you very much for your help!
... View more
data have;
input Name $ Gender $ City $12.;
datalines;
Srilakshmi Female Hyderabad
Vamika Female Bangalore
Prajwal Male Mumbai
;
run;
data want;
set have;
City = substr(City, 1, 1);
Gender = substr(Gender, 1, 1);
Name = substr(scan(Name, 1), 1, 1);
drop Name Gender City;
left_to_right=catx(' ',name,gender,city);
right_to_left=catx(' ',city,gender,name);
run;
Hi Guys ,
Here i want to extract first letter from each variable left to right and right to left
is it correct way or any other method to achieve could you please give solution
... View more
Hello everybody, fairly new in the world of SAS, a curious person,say, learning in his own time. I am trying to riddle out how to make a successful POST/GET request to REST API using %macro and JSON as the primary payload and then set up a table that tracks a history of past requests and responses. Set this task to myself as it's one of the more common things people aim to do in other languages. Working with APIs. While, it takes me about 10 minutes to write such logic in JS or Python without any headaches, though I cannot string up a working logic in SAS using %macro (a term function could also be used as a synonym I guess?). A non-macro approach clicked using datalines and a hard-coded value as a prompt. I am now well aware that datalines will not budge when using macro logic so I went with put, but still not a single budge. Here's the code that I have managed to jot down so far. The API is crudcrud.com allowing up to 100 free requests. %macro api_post_request(prompt=);
%let api_url=url;
filename json_in temp;
data _null_;
file in;
put "{
""username"":""&prompt""
}"
;
run;
filename resp temp;
proc http method="POST"
url="&api_url
ct="application/json"
in=json_in
out=resp;
headers
"Content-Type"="application/json";
run;
%mend;
%api_post_request(prompt=Player1); Fierce thanks!
... View more
Hi,
I need some help with writing a SAS code to handle the following scenario.
I have a data set that has multiple sites; each site has multiple patients; and each patient can have data of up to 7 days (one row represents one day). The data set has form start and save time. Data set is also setup to have no duplicates. First day data of each patient should always have the previous save and open time (both are user defined variables) as NULL. e.g., sr.1, 8, and 9 will have previous open and save time variables as NULL. And using these variables, I want to calculate the the following for each patient at a site:
number of hours a patient took between today's and yesterday's start times (i.e., from today's start to previous start) and
number of hours a patient took between today's open and yesterday's start times (i.e., from today's start to previous day save)
Sr.
PT
SITE
START_TIME
SAVE_TIME
1
001
01
4/9/2024 16:44
4/9/2024 16:46
2
001
01
4/10/2024 16:39
4/10/2024 16:40
3
001
01
4/11/2024 16:07
4/11/2024 16:08
4
001
01
4/12/2024 16:05
4/12/2024 16:06
5
001
01
4/13/2024 20:05
4/13/2024 20:06
6
001
01
4/14/2024 19:31
4/14/2024 19:52
7
001
01
4/15/2024 16:25
4/15/2024 16:25
8
002
01
4/15/2024 16:19
4/15/2024 16:20
9
003
01
4/15/2024 16:21
4/15/2024 16:22
10
002
02
4/3/2024 18:34
4/3/2024 18:41
11
002
02
4/4/2024 18:03
4/4/2024 18:09
12
002
02
4/6/2024 21:11
4/6/2024 21:14
13
002
02
4/6/2024 21:14
4/6/2024 21:16
14
002
02
4/7/2024 18:17
4/7/2024 18:20
15
002
02
4/8/2024 18:12
4/8/2024 18:14
16
002
02
4/9/2024 18:06
4/9/2024 18:08
17
004
02
4/5/2024 18:03
4/5/2024 18:10
18
004
02
4/6/2024 16:27
4/6/2024 16:32
19
004
02
4/7/2024 19:18
4/7/2024 19:22
20
004
02
4/8/2024 18:01
4/8/2024 18:07
21
004
02
4/9/2024 18:06
4/9/2024 18:16
22
004
02
4/10/2024 18:08
4/10/2024 18:10
23
004
02
4/11/2024 19:22
4/11/2024 19:26
24
005
02
4/8/2024 18:05
4/8/2024 18:07
25
005
02
4/9/2024 19:32
4/9/2024 19:34
26
005
02
4/10/2024 18:45
4/10/2024 18:47
27
005
02
4/11/2024 18:02
4/11/2024 18:04
28
005
02
4/12/2024 18:04
4/12/2024 18:07
29
005
02
4/13/2024 18:01
4/13/2024 18:03
30
005
02
4/14/2024 18:06
4/14/2024 18:08
Thanks so much in advance for all the help.
... View more
Hi - First post here and fairly new to SAS. I have found a lot of help on this board and hoping I can get some on this issue. I feel like I should be using first./last. by looking at other examples but my calculations aren't coming out correctly (or at all) I have a transaction file with the payment_amt and adjustment_amt in two different fields. I am using a data step to combine these all into one column as I feel that would be easier to do the calculation. I am also given an EOD balance that I can compare to the balance currently in our system. Obviously, doing these calculation per line cause a large number of "balance exceptions" How can I calculate the total adjustment & payment amount if there are multiple transactions for an account on different lines? This is the dataset that I'm trying to do the calculations on (imported from a csv) - "newtrans_amt" is the amount I've combined PAYMENT_AMT and ADJUSTMENT_AMT into data combinekeys; set re_pay; PAYMENT_AMT = tranwrd(PAYMENT_AMT, ",", ""); ADJUSTMENT_AMT = tranwrd(ADJUSTMENT_AMT, ",", ""); EOD_BALANCE = tranwrd(EOD_BALANCE, ",", ""); PAYMENT_AMT = compress(PAYMENT_AMT); ADJUSTMENT_AMT = compress(ADJUSTMENT_AMT); EOD_BALANCE = compress(EOD_BALANCE); format newkey $10.; if ADJUSTMENT_KEY ne "" then newkey = ADJUSTMENT_KEY; IF PAYMENT_KEY ne "" then newkey = PAYMENT_KEY; if ADJUSTMENT_AMT ne "" then newtrans_amt = ADJUSTMENT_AMT; if PAYMENT_AMT ne "" then newtrans_amt = PAYMENT_AMT*-1; run; proc sort data=combinekeys; by CONSUMERNO; run; From this point I'm kind of lost on how to: -total the total transaction amount using "newtrans_amt" by CONSUMERNO -If I can get a valid amount on in newtrans_amt, I should be able to take care of comparing that amount with what our system balance will be. to match with EOD_BALANCE. Any help is greatly appreciated.
... View more