11-06-2022
jjjch
Obsidian | Level 7
Member since
10-17-2016
- 27 Posts
- 66 Likes Given
- 2 Solutions
- 3 Likes Received
-
Latest posts by jjjch
Subject Views Posted 7647 10-13-2020 02:15 PM 7647 10-13-2020 02:13 PM 7738 10-13-2020 01:14 PM 2744 04-01-2020 08:39 PM 1545 02-27-2020 12:08 PM 1559 02-27-2020 11:22 AM 1561 02-27-2020 11:18 AM 1630 02-26-2020 11:04 PM 1384 09-14-2019 05:34 PM 962 08-28-2019 01:52 PM -
Activity Feed for jjjch
- Liked Your SAS Global Forum paper: Now with GitHub! for ChrisHemedinger. 08-05-2022 08:33 AM
- Liked Creating A New York Times-Like Tile Grid U.S. Map With SAS ODS Graphics for tc. 01-19-2022 08:04 AM
- Liked Fun with SAS ODS Graphics: Rain Cloud Plot for yabwon. 10-04-2021 08:09 AM
- Liked How do I write a macro to...import multiple text files that have the same format? for Reeza. 04-22-2021 11:57 AM
- Liked Re: axis on log scale for PGStats. 10-24-2020 05:27 PM
- Liked Re: Is there a SAS function to determine a string ends with another string? for FreelanceReinh. 10-13-2020 07:14 PM
- Liked Re: Is there a SAS function to determine a string ends with another string? for Reeza. 10-13-2020 07:14 PM
- Liked Re: Is there a SAS function to determine a string ends with another string? for Reeza. 10-13-2020 07:14 PM
- Liked Re: Is there a SAS function to determine a string ends with another string? for novinosrin. 10-13-2020 07:14 PM
- Posted Re: Is there a SAS function to determine a string ends with another string? on SAS Programming. 10-13-2020 02:15 PM
- Posted Re: Is there a SAS function to determine a string ends with another string? on SAS Programming. 10-13-2020 02:13 PM
- Posted Is there a SAS function to determine a string ends with another string? on SAS Programming. 10-13-2020 01:14 PM
- Liked Fun with SAS ODS Graphics: 3 Cheers for the Red, White, and Blue (Polygons) for tc. 07-02-2020 11:27 PM
- Liked Re: Solving an equation , non linear for RobPratt. 06-21-2020 11:49 AM
- Liked Re: sas annotate example output for Rick_SAS. 06-20-2020 12:52 PM
- Liked Kaplan-Meier Survival Plotting Macro %NEWSURV for JeffMeyers. 06-17-2020 06:48 PM
- Liked Re: Proc Optmodel and CVRP : Turning off the decomposition algo | LSO for josgri. 06-17-2020 04:53 PM
- Liked Re: Proc Optmodel and CVRP : Turning off the decomposition algo | LSO for RobPratt. 06-17-2020 04:53 PM
- Liked Looking for Feedback and Suggestions: New CONSORT Diagram Macro for JeffMeyers. 06-16-2020 05:31 PM
- Liked Beautiful HTML Charts from SAS for NPashaP. 04-15-2020 10:39 PM
-
Posts I Liked
Subject Likes Author Latest Post 13 6 17 13 1 -
My Liked Posts
Subject Likes Posted 2 04-01-2020 08:39 PM 1 09-14-2019 05:34 PM
10-13-2020
02:15 PM
Thank you, Reeza. Your solution also works. I just hope SAS can provide a string function or operator for endswith().
... View more
10-13-2020
02:13 PM
Thank you, @novinosrin
... View more
10-13-2020
01:14 PM
We can use "=:" to determine whether aString starts with 'ABC' like below:
if aString=:'ABC';
But how to determine aString ends with 'ABC'? Is there an existing function or operator for that? Thanks.
... View more
04-01-2020
08:39 PM
2 Likes
add "missing" to your "vbar ... " statements. like below:
DATA cars1;
infile DATALINES dsd missover;
INPUT var val;
CARDS;
,0.2099
0,0.4749
1,0.7827
;
RUN;
proc sgplot data=cars1;
vbar var / response=val group=var
datalabel datalabelattrs=(weight=bold) missing;
yaxis grid label='Actual Default Rate' ;
run;
DATA cars2;
infile DATALINES dsd missover;
INPUT var $ val;
CARDS;
,0.2099
A,0.4749
B,0.7827
;
proc sgplot data=cars2;
vbar var / response=val group=var
datalabel datalabelattrs=(weight=bold) missing;
yaxis grid label='Actual Default Rate' ;
run;
... View more
02-27-2020
12:08 PM
Hi Tom,
I have about 250 macro functions. I want to know how many seconds they need to be compiled. But looks like it is not easy to find out.
Because I may need to schedule my program to run every 15 minutes or every 10 minutes, and I hope using pre-compiled macros could save me some time.
Thanks.
... View more
02-27-2020
11:22 AM
Hi Tom, thank you for your reply. I got the below error for the statement.
%include mysource(*);
ERROR: Cannot %INCLUDE member (*) in the aggregate MYSOURCE.
%include mysource(my_macro1, my_macro2);
Works though.
... View more
02-27-2020
11:18 AM
Hi Patrick, thank you for your reply. Looks like I still need to add " / store " to my macros and compile the macros one by one.
And I hope there is a real example of "Using SAS Catalogs as Autocall Libraries" in the document to show us how it works.
... View more
02-26-2020
11:04 PM
I save each macro function into a SAS file and put them all in my_macro_folder. /*my_macro1.sas file*/
%macro my_macro1();
...
%mend;
/*my_macro2.sas file*/
%macro my_macro2();
...
%mend; And below is the way that I call those macros. options sasautos=("my_macro_folder" sasautos);
%my_macro1()
%my_macro2()
... As my program evolves and adds more functions, the number of macro functions increases, and my program becomes slower and slower. Recently I noticed that it took 13 minutes to run the first time, then 8 minutes to run the second time for the exact same input. What are the possible ways to speed up the program? Looks like switching to the stored compiled macro programs is a way of improving the efficiency. Then I will need to add " / store source" to each macro function and combine them into one file like below. Is there a tool to do it automatically? Because I would like to keep using the sasautos way to develop and test my program while only using the stored compiled macro programs in the production environment, a tool to automatically transform all my macros into these stored compiled macro programs would save developers like me a lot of time. libname mylib 'my_macro_folder';
options mstored sasmstore=mylib;
/*my_macro1.sas file*/
%macro my_macro1() / store source;
...
%mend;
/*my_macro2.sas file*/
%macro my_macro2() / store source;
...
%mend; Thank you!
... View more
09-14-2019
05:34 PM
1 Like
Maybe you need to add two records having missing values with Grade equal to 8 and 9? Like below: data test;
length Q $ 10;
input Q $ Q1 Grade Value;
datalines;
Calc_1 1 8 77
Calc_1 1 9 81
Calc_2 2 8 69
Calc_2 2 9 73
Calc_3 3 8 64
Calc_4 . 8 .
Calc_4 . 9 .
Non-Calc_1 1 8 83
Non-Calc_1 1 9 83
Non-Calc_2 2 8 84
Non-Calc_2 2 9 86
Non-Calc_3 3 8 83
Non-Calc_3 3 9 84
;
run;
... View more
08-28-2019
01:52 PM
This is what I created: And below is what I wanted: How to implement it? Thank you! Below are my codes: %macro randomNormal(mean=0, stddev=1, N=100, outDS=);
data &outDS.(keep=x);
call streaminit(datetime());
do i = 1 to &N;
x = rand("NORMAL", &mean, &stddev);
output;
end;
run;
%mend;
%randomNormal(mean=100, stddev=10, N=100, outDS=One);
%randomNormal(mean=15, stddev=10, N=100, outDS=Two);
data myData;
set One(in=in1) Two(in=in2);
if in1 then Name='One';
if in2 then Name='Two';
run;
proc sgpanel data=myData;
panelby Name / columns=1;
histogram x / binwidth=1;
run;
... View more
- Tags:
- sgpanel
05-17-2019
03:47 PM
Thank you very much for your reply!
... View more
05-15-2019
05:41 PM
Thank you for replying. For example, my SAS codes created 35 datasets, but they are not sorted by name, therefore it is difficult for me to find the dataset I want to check. By "in the relevant library", do you mean I create multiple libs, and put different datasets into different lib? I don't like that.
... View more
05-15-2019
05:28 PM
When multiple data sets are created by my SAS codes, they can be view in the "Output Data" tab. I wish they are sorted by name in the "Output Data" tab so that it is easier to check them. I looked through all the options, but could not find one. Could you help me? Thank you!
... View more
05-09-2019
09:33 AM
Hi Jeff, in addition to current input dataset which has two variables of BEFORE and AFTER, it would be convenienct for user to creat the circle graph by adding a third variable like LinkCount in Sanjay's example.If the third variable is missing, then assume it is 1 by default. data soccer;
input From $1-10 To $11-20 LinkCount;
datalines;
USA Spain 2
USA Germany 3
England Germany 2
England Italy 3
England Norway 1
England Spain 2
England Belgium 2
England Brazil 1
France Belgium 1
Italy Argentina 1
Argentina Argentina 9
Austria Austria 6
Belgium Belgium 8
Brazil Brazil 8
Bulgaria Bulgaria 7
Denmark Denmark 8
England England 6
France France 9
Germany Germany 12
Greece Greece 6
Italy Italy 6
Norway Norway 6
Spain Spain 8
;
run;
... View more
04-10-2019
12:25 PM
ballardw, thank you for your help. I ended up with writing a function like below. /*define the function*/
libname myfunc "...";
proc fcmp outlib=myfunc.util.datetime;
function hoursInADay(myDate);
if missing(myDate) then return(.);
jg_t_year = year(myDate);
jg_t_shortday = nwkdom(2, 1, 3, jg_t_year);
jg_t_longday = nwkdom(1, 1, 11, jg_t_year);
if myDate=jg_t_shortday then jg_num_of_hours=23;
else if myDate=jg_t_longday then jg_num_of_hours=25;
else jg_num_of_hours=24;
return(jg_num_of_hours);
endsub;
run;
/*test the function*/
libname myfunc "...";
options cmplib=myfunc.util;
data _NULL_;
array myDates{3} _temporary_ ('28MAR2019'd, '10MAR2019'd, '4NOV2018'd);
do i=1 to dim(myDates);
hours = hoursInADay(myDates{i});
put myDates{i}=yymmdd10.;
put hours=/;
end;
run; And the results are what I expected: myDates[1]=2019-03-28 hours=24 myDates[2]=2019-03-10 hours=23 myDates[3]=2018-11-04 hours=25
... View more