![DavidPhillips2 DavidPhillips2](https://communities.sas.com/legacyfs/online/a71845_tempImage2038697462371567172.png)
08-25-2024
DavidPhillips2
Rhodochrosite | Level 12
Member since
10-23-2014
- 837 Posts
- 90 Likes Given
- 37 Solutions
- 27 Likes Received
-
Latest posts by DavidPhillips2
Subject Views Posted 724 02-20-2024 01:01 PM 757 02-20-2024 12:36 PM 1758 02-19-2024 01:27 PM 1791 02-19-2024 12:05 PM 1815 02-19-2024 11:58 AM 1842 02-19-2024 11:36 AM 1884 02-19-2024 09:51 AM 2184 10-06-2023 01:40 PM 2195 10-06-2023 01:14 PM 1768 06-28-2022 08:46 AM -
Activity Feed for DavidPhillips2
- Posted Re: Semi Colon in Macro and Datastep on SAS Programming. 02-20-2024 01:01 PM
- Posted Semi Colon in Macro and Datastep on SAS Programming. 02-20-2024 12:36 PM
- Posted Re: Adding quotes on both sides of a macro and removing leading spaces. on SAS Programming. 02-19-2024 01:27 PM
- Posted Re: Adding quotes on both sides of a macro and removing leading spaces. on SAS Programming. 02-19-2024 12:05 PM
- Posted Re: Adding quotes on both sides of a macro variable and removing leading spaces. on SAS Programming. 02-19-2024 11:58 AM
- Posted Re: Adding quotes on both sides of a macro and removing leading spaces. on SAS Programming. 02-19-2024 11:36 AM
- Posted Adding quotes on both sides of a macro and removing leading spaces. on SAS Programming. 02-19-2024 09:51 AM
- Posted Re: Validate if Character is a Number on SAS Programming. 10-06-2023 01:40 PM
- Posted Validate if Character is a Number on SAS Programming. 10-06-2023 01:14 PM
- Posted Re: Self Join on Time Series SAS Visual Analytics on SAS Visual Analytics. 06-28-2022 08:46 AM
- Posted Re: Self Join on Time Series SAS Visual Analytics on SAS Visual Analytics. 06-27-2022 06:35 PM
- Posted Re: Self Join on Time Series SAS Visual Analytics on SAS Visual Analytics. 06-27-2022 05:04 PM
- Liked Re: Self Join on Time Series SAS Visual Analytics for Stu_SAS. 06-27-2022 05:04 PM
- Posted Re: Self Join on Time Series SAS Visual Analytics on SAS Visual Analytics. 06-27-2022 02:58 PM
- Posted Re: Self Join on Time Series SAS Visual Analytics on SAS Visual Analytics. 06-24-2022 04:54 PM
- Posted Self Join on Time Series SAS Visual Analytics on SAS Visual Analytics. 06-23-2022 11:05 AM
- Posted Re: Sort Execution Failure when Writing to and from Oracle with Proc SQL. on SAS Programming. 04-19-2022 08:57 AM
- Liked Re: Sort Execution Failure when Writing to and from Oracle with Proc SQL. for Kurt_Bremser. 04-19-2022 08:52 AM
- Posted Re: Sort Execution Failure when Writing to and from Oracle with Proc SQL. on SAS Programming. 04-18-2022 08:51 AM
- Posted Sort Execution Failure when Writing to and from Oracle with Proc SQL. on SAS Programming. 04-15-2022 11:50 AM
-
Posts I Liked
Subject Likes Author Latest Post 3 1 1 1 1 -
My Liked Posts
Subject Likes Posted 1 08-03-2021 04:58 PM 1 08-03-2021 04:55 PM 2 07-26-2021 12:37 PM 1 07-21-2021 01:50 PM 1 07-21-2021 10:36 AM
02-20-2024
12:36 PM
How can I include a semi-colon in the variable created in a data step? I found a post that talked about superq, but it seems to not work for me in this case.
data _null_;
length result1 $3000;
result1 = catx(' ', result1, 'Hello world', 40.);
call symputx('defineAnalysis1', result1, 'g');
run;
/*This shows Hello world*/
/*how to make it show Hello world;*/
%put &defineAnalysis1;
... View more
02-19-2024
01:27 PM
Thanks for posting the data step code. That is much cleaner.
... View more
02-19-2024
12:05 PM
I should be able to convert the code block you posted to what I need. It looks like i needed to use %str(%") and tranward.
... View more
02-19-2024
11:58 AM
1 The SAS System 11:56 Monday, February 19, 2024
1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Program';
4 %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5 %LET _CLIENTPROJECTPATH='';
6 %LET _CLIENTPROJECTPATHHOST='';
7 %LET _CLIENTPROJECTNAME='';
8 %LET _SASPROGRAMFILE='';
9 %LET _SASPROGRAMFILEHOST='';
10
11 ODS _ALL_ CLOSE;
12 OPTIONS DEV=PNG;
13 GOPTIONS XPIXELS=0 YPIXELS=0;
14 FILENAME EGSR TEMP;
15 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16 STYLE=HtmlBlue
17 STYLESHEET=(URL="file:///C:/Program%20Files/SAS7Home/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
18 NOGTITLE
19 NOGFOOTNOTE
20 GPATH=&sasworklocation
21 ENCODING=UTF8
22 options(rolap="on")
23 ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
24
25 GOPTIONS ACCESSIBLE;
26 options mprint;
27 %global academicPeriods fAcadP;
28
29 %let fAcadP=201010;
30
31 %macro Parameters(n);
32 %let academicPeriods = "%eval(&fAcadP. +&i*100)";
33 %do i=2 %to &n - 1;
34 %let academicPeriods = &academicPeriods ,"%eval(&fAcadP. +&i*100)";
35 %end;
36 %let academicPeriods =&academicPeriods, "%eval(&fAcadP +&n*100)";
37 %mend;
38 %Parameters(3);
WARNING: Apparent symbolic reference I not resolved.
WARNING: Apparent symbolic reference I not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:
201010 +&i*100
ERROR: The macro PARAMETERS will stop executing.
39
40 GOPTIONS NOACCESSIBLE;
41 %LET _CLIENTTASKLABEL=;
42 %LET _CLIENTPROCESSFLOWNAME=;
43 %LET _CLIENTPROJECTPATH=;
44 %LET _CLIENTPROJECTPATHHOST=;
45 %LET _CLIENTPROJECTNAME=;
46 %LET _SASPROGRAMFILE=;
47 %LET _SASPROGRAMFILEHOST=;
48
49 ;*';*";*/;quit;run;
50 ODS _ALL_ CLOSE;
51
52
2 The SAS System 11:56 Monday, February 19, 2024
53 QUIT; RUN;
54
options mprint; %global academicPeriods fAcadP; %let fAcadP=201010; %macro Parameters(n); %let academicPeriods = "%eval(&fAcadP. +&i*100)"; %do i=2 %to &n - 1; %let academicPeriods = &academicPeriods ,"%eval(&fAcadP. +&i*100)"; %end; %let academicPeriods =&academicPeriods, "%eval(&fAcadP +&n*100)"; %mend; %Parameters(3);
... View more
02-19-2024
11:36 AM
Mark, thanks for replying to my thread.
I should have included the above let statements above:
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: 201010 +&i*100 ERROR: The macro PARAMETERS will stop executing.
%global academicPeriods fAcadP;
%let fAcadP=201010;
%macro Parameters(n);
%let academicPeriods = "%eval(&fAcadP. +&i*100)";
%do i=2 %to &n - 1;
%let academicPeriods = &academicPeriods ,"%eval(&fAcadP. +&i*100)";
%end;
%let academicPeriods =&academicPeriods, "%eval(&fAcadP +&n*100)";
%mend;
%Parameters(3);
... View more
02-19-2024
09:51 AM
I have a set of macro variables that I generated statically that I need to generate dynamically with a number of years parameter. The macro variable needs to have quotes on both sides and no leading spaces. An easy way to do this might be without making a macro loop.
The text that I want is:
("201110", "201210", "201310")
when the parameter is 3
("201110", "201210")
when the parameter is 2
The closest I have so far is the script below.
%global academicPeriods;
%let fAcadP=201010;
%let fAcadYS=2009;
%let academicPeriods = %str();
%macro Parameters(n);
%let academicPeriods = %str();
%do i=1 %to &n - 1;
%put &academicPeriods;
%let academicPeriods = %sysfunc(cat(&academicPeriods, %eval(&fAcadP. +&i*100)", "));
%end;
%let academicPeriods =&academicPeriods %eval(&fAcadP +&n*100);
%mend;
%Parameters(3);
%put(&academicPeriods);
... View more
10-06-2023
01:14 PM
I'm working on a data integrity check to validate if a character field only contains values that are numbers. The goal is to populate have.isnumber with values Y or N depending on if the value is a number or not. I caught instances where there are two decimals in the character field rather than one. E.g. 3..14 instead of 3.14. Is there a way to flag this in a data step?
proc sql;
create table have
(
characterField varchar2(10)
);
insert into have (characterField) values ('3.22');
insert into have (characterField) values ('4..22');
insert into have (characterField) values ('N/A');
quit;
data want; set have;
if characterField = '3.22' then IsNumber = 'Y';
if characterField = '4..22' then IsNumber = 'N';
if characterField = 'N/A' then IsNumber = 'N';
run;
... View more
06-28-2022
08:46 AM
The methodology of using distinct with two parameters is very practical. I'm sure I'll use it for something else. Unfortunately, I need to know if a student was enrolled from 1 to a large number of semesters from their starting semester whether they have an enrollment record or not so it looks like I'm stuck creating a cross-joined structure, which is a small version of big data.
... View more
06-27-2022
06:35 PM
I can add graduated in general to the enrollment record by merging records together. I’m picturing graduated on the To semester. Then In theory i should be able to do if statements on the To semester. There is a business rule of graduating not counting if it is before the From semester, I might need to do that part of the logic on the dataset before VA.
... View more
06-27-2022
05:04 PM
This solution might work. I need to add some If logic to use this method for a particular business use case. If the student graduated before the semester, do not count them as enrolled for any record of that student after the From semester A student can have one or many degrees; I think I can include redundancy with degrees and still use this logic. I'll look into this methodology tomorrow; hopefully, there will not be a complication with mixed aggregation levels in the if / distinct logic.
... View more
06-27-2022
02:58 PM
Ted, the SQL code produces all of the following that you asked for.
... View more
06-24-2022
04:54 PM
I looked over the documentation for these features. I'm not seeing a feature that will allow the type of report I included with the example.
In time one a student is enrolled in time X then display 1.
A trickier one is if the student graduated before time X display 1.
... View more
06-23-2022
11:05 AM
I’m looking to see if Visual Analytics has a feature that can make what I was manually structuring on the interface side using some sort of time linking like parallel periods or the like without creating a new table via self joins prior to the interface layer.
I have an enrollment table that has one record per student per semester. I’d like to use the enrollment table to display if students are still enrolled in any given semester 30 semesters out. The display needs to be the number of students enrolled in the base enrollment semester, and the number of students still enrolled in the other semester and were enrolled in the base semester.
I created a table by hand with the fields (From_semeseter, To_semester, enrolled) then displayed the information in a tabular format. The structure was created by joining the enrollment table self-joining the enrollment table 30 times. The problem is that creating the structure maxes out my tiny system resources.
proc sql;
/*enrollment table*/
create table enrollment (
Student char(10),
Term_num int
);
insert into enrollment (student, term_num) values ('Bob', 1);
insert into enrollment (student, term_num) values ('Bob', 2);
insert into enrollment (student, term_num) values ('Bob', 4);
/*self joined enrollment*/
create table self_joined_enrollment (
Student char(10),
From_Semester int,
To_Semester int,
enrolled int
);
insert into self_joined_enrollment(student, From_semester, to_Semester, enrolled) values ('Bob', 1, 1, 1);
insert into self_joined_enrollment(student, From_semester, to_Semester, enrolled) values ('Bob', 1, 2, 1);
insert into self_joined_enrollment(student, From_semester, to_Semester, enrolled) values ('Bob', 1, 3, 0);
insert into self_joined_enrollment(student, From_semester, to_Semester, enrolled) values ('Bob', 1, 4, 1);
insert into self_joined_enrollment(student, From_semester, to_Semester, enrolled) values ('Bob', 2, 2, 1);
insert into self_joined_enrollment(student, From_semester, to_Semester, enrolled) values ('Bob', 2, 2, 1);
insert into self_joined_enrollment(student, From_semester, to_Semester, enrolled) values ('Bob', 2, 4, 1);
insert into self_joined_enrollment(student, From_semester, to_Semester, enrolled) values ('Bob', 3, 3, 0);
insert into self_joined_enrollment(student, From_semester, to_Semester, enrolled) values ('Bob', 3, 4, 0);
insert into self_joined_enrollment(student, From_semester, to_Semester, enrolled) values ('Bob', 4, 4, 1);
/*example of data displayed*/
select From_Semester, to_semester, sum(enrolled) as Students_Still_Enrolled
from self_joined_enrollment
where From_Semester =1 and to_semester=2;
quit;
... View more