03-24-2020
frupaul
Quartz | Level 8
Member since
03-17-2017
- 95 Posts
- 19 Likes Given
- 1 Solutions
- 3 Likes Received
-
Latest posts by frupaul
Subject Views Posted 794 07-03-2019 06:48 AM 842 12-11-2018 08:04 AM 723 12-03-2018 07:12 AM 1948 11-20-2018 02:12 PM 2011 11-20-2018 12:06 PM 4435 11-04-2018 03:39 PM 871 09-14-2018 12:11 PM 714 09-08-2018 02:18 AM 3285 09-07-2018 07:21 PM 3313 09-07-2018 05:31 PM -
Activity Feed for frupaul
- Posted datelines statement returning incomplete result on SAS Programming. 07-03-2019 06:48 AM
- Liked Re: Difficulty saving user defined format for Tom. 12-11-2018 10:00 AM
- Posted Difficulty saving user defined format on SAS Programming. 12-11-2018 08:04 AM
- Posted SAS DI not recognising field names on SAS Data Management. 12-03-2018 07:12 AM
- Posted Re: Limitation of tranwrd function on SAS Programming. 11-20-2018 02:12 PM
- Liked Re: Limitation of tranwrd function for data_null__. 11-20-2018 02:10 PM
- Posted Limitation of tranwrd function on SAS Programming. 11-20-2018 12:06 PM
- Posted NOTE: The query requires remerging summary statistics back with the original data. on SAS Programming. 11-04-2018 03:39 PM
- Posted Data format conversion on SAS Programming. 09-14-2018 12:11 PM
- Posted Re: I need program for this output on SAS Programming. 09-08-2018 02:18 AM
- Liked Re: transpose and concat for PGStats. 09-08-2018 01:09 AM
- Posted Re: transpose and concat on SAS Programming. 09-07-2018 07:21 PM
- Liked Re: transpose and concat for ballardw. 09-07-2018 07:11 PM
- Posted transpose and concat on SAS Programming. 09-07-2018 05:31 PM
- Posted Re: Duduplication accross rows on SAS Programming. 08-28-2018 04:28 PM
- Liked Re: Duduplication accross rows for FreelanceReinh. 08-22-2018 04:54 PM
- Liked Re: Duduplication accross rows for novinosrin. 08-22-2018 04:54 PM
- Posted Re: Deduplication across rows - extension on SAS Programming. 08-22-2018 11:22 AM
- Liked Re: Deduplication across rows - extension for Jagadishkatam. 08-22-2018 11:20 AM
- Posted Re: Duduplication accross rows on SAS Programming. 08-22-2018 11:04 AM
-
Posts I Liked
Subject Likes Author Latest Post 1 1 1 1 1 -
My Liked Posts
Subject Likes Posted 2 08-22-2018 02:10 AM 1 06-18-2017 03:31 AM
08-14-2018
07:12 AM
1 Like
Hope below query solve your problem data abc; input datetime $23.; datalines; 19/07/2018 09:34:02 AM 18/07/2018 09:19:50 PM 13/07/2018 06:28:39 PM 12/07/2018 09:58:06 AM 12/07/2018 08:54:34 AM run; data test; set abc; date_new=input(scan(datetime,1,''),ddmmyy10.); format date_new ddmmyy10.; run;
... View more
08-03-2018
09:48 AM
1 Like
You loop from 8 to 1, but use i+1 in the loop, so it tries to access element 9 in the first iteration which does not exist. That is a conceptual mistake.
... View more
07-26-2018
12:53 PM
1 Like
Run this and post the output. If what you're saying is happening, the compare will not be equal. Otherwise, you have some other issue.
data class;
set sashelp.class;
run;
libname demo 'C:\_localdata\temp\';
data demo.class;
set class;
run;
proc sql;
create table demo.class2 as
select *
from class;
quit;
proc compare data=demo.class compare=demo.class2;
run;
... View more
07-26-2018
07:32 AM
It is no harder to transpose character variable, although you are REQUIRED to use the VAR statement.
data Customer_Survey;
infile datalines dlm=',';
length Survey_ref $8 TQuestion1 $90 TStaff_Name $20 TCompany_Name $15;
input Survey_ref $ TQuestion1 $ TStaff_Name $ TCompany_Name $;
cards;
PPTV, How Likely are you to recommend Alex Jefferson from Morrisons?,Alex Jefferson,Morrisons
JJNT, How Likely are you to recommend Morrisons to a Friend?,Pablo, Morrisons
;
proc transpose data=Customer_Survey out=want ;
by Survey_ref TQuestion1 notsorted ;
var TStaff_Name TCompany_Name ;
run;
... View more
07-25-2018
10:28 PM
Sorry i thought it was self explanatory. Here is the full example data set: and code that generates that: data Ranking; INFILE DATALINES DLM=',' missover; length CustID L1 $20 L2 $20 L3 $20 L4 $20 L5 $20 L6 $20 L7 $20 L8 $20; input CustID L1 $ L2 $ L3 $ L4 $ L5 $ L6 $ L7 $ L8 $; cards; 1,CEO,Department Head,Senior Manager,Manager, Senior Analyst, Peter, , 2,Major,Vice President, CEO, Department Head, Senior Manager,Manager,Senior Analyst, Andrew 3,Technical Chief, CEO, Department Head, Senior Manager, Manager, Senior Analyst,James ;
... View more
07-24-2018
05:32 PM
Use a CASE statement to avoid adding quotes around missing values.
Make a space delimited list instead of comma delimited list to avoid the extra commas. SAS doesn't need commas between the values in the list.
proc sql noprint ;
select case when missing(city) then city else quote(trim(city)) end
, case when missing(house) then house else quote(trim(house)) end
into :city_list separated by ' '
, :house_list separated by ' '
from test
;
quit;
If you want to you can remove the trailing unquoted (and un-macro quoted) spaces with a simple %LET . But is it probably not needed.
%let city_list=&city_list;
... View more
07-24-2018
12:23 PM
So you need quotes around string literals. So either add the quotes when making the macro variable. You can use the QUOTE() function in your SQL query.
It is a common enough problem to convert a space delimited list of words into a list of quoted words that there are many macros available to make the conversion. For example: %qlist
But for simple list with just a single space between the words you can do it with a simple call to TRANWRD() function.
data subset;
set stats;
where subs in ("%sysfunc(tranwrd(&List_subs,%str( )," "))");
run;
You can clean up a user entered list that might have multiple spaces between the words by using the COMPBL() function.
%let qlist=%sysfunc(compbl(&list_subs));
%let qlist="%sysfunc(tranwrd(&qlist,%str( )," "))";
... View more
07-23-2018
03:24 PM
TRANWRD is for a word but you have two words so it's not going to match. Is it possible to have multiple iterations of a persons name in the text? And is it guaranteed that the name is always at the end?
You do want a TRANSLATE/TRANS family of functions for sure though. If you have multiple occurrences it could be problematic though.
@frupaul wrote:
Hi Everyone,
I have the following data set:
Code used to create above data set is:
data Questions; length Question $100 Name $20; infile datalines dlm=','; input Question $ Name $ ; cards; When was your last interaction with Pablo Matinee,Pablo Matinee When was your last interaction with Lucien Koku,Lucien Koku ;
I want to replace every occurrence of the customer Name in the Question with [Name]. So what i intend to achieve is this:
What i have written so far is:
data New; set Questions; tranwrd(Question,Name,"%str(%[)Name%str(%])"); run;
but this has not worked. Please can anyone suggest a solution?
Thanks,
... View more
07-20-2018
03:22 AM
Export to csv from Excel and read with a custom data step, or remove the first line in Excel.
Both libname xlsx and proc import do not support variable names in a line other than the first.
... View more
07-18-2018
06:22 PM
HI Andreas, Thanks for the proposed solution. It worked but i got a warning. Im guessing it was because of the use of the countw function. However, when i used the scan(ManagerList, -1) and scan(ManagerList, -2) it worked without a warning
... View more
04-12-2018
02:13 AM
There is a discussion on stackoverflow: https://stackoverflow.com/questions/201323/how-to-validate-an-email-address-using-a-regular-expression about validating e-mail addresses. If your code needs to be 100% RFC822 compliant, the expression is a bit more complex 😉
... View more
04-11-2018
08:53 AM
Please mark @RW9's answer as solution, I just added a very small improvement.
... View more
01-30-2018
10:13 AM
Hi frupaul,
The easiest is to use the Association node in SAS Enterprise Miner. However, if you want to understand the technical side of Association node, take a look at this document. It describes how how PROC DMDB, PROC ASSOC, and PROC RULEGEN work together.
http://support.sas.com/documentation/onlinedoc/miner/em43/rulegen.pdf
Example of SAS Enterprise Miner Association node
Data Mining Using SAS® Enterprise Miner : A Case Study Approach, Second Edition - Chapter 5
If you have specific questions about your data, open a Technical Support track here and we'll be happy to help you further!
Hope this helps!
Jess Mayo
SAS Technical Support
... View more
11-08-2017
04:25 PM
Any books or publications you can refer me to? Thanks
... View more