LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2011, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 2 May 2011 20:44:53 -0400
Reply-To:   Nat Wooding <nathani@VERIZON.NET>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Nat Wooding <nathani@VERIZON.NET>
Subject:   Re: List Processing and Combinations
In-Reply-To:   <03e301cc0928$10d3a770$327af650$@carolina.rr.com>
Content-Type:   text/plain; charset="us-ascii"

Jason

I feel like I'm missing something here but take a look at the following code which assumes that the student data are stored in a string and not in individual variables.

Nat Wooding

Data Jason; informat string $50.; input string &; cards; Math 1 93 4 Math 2 85 3 Read 1 72 2 Sci 3 52 1 ; Data jason; set jason; Course = scan( string , 1 ); Semester = Compress( 'SEM' || scan( string, 2 ));

SS = scan( string, 3 ); AL = scan( string, 4 );

newline1 = Catx( '_' , course , semester, 'ss' , ss ); newline2 = Catx( '_' , course , semester, 'al' , al );

run;

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Jason Schoeneberger Sent: Monday, May 02, 2011 8:22 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: List Processing and Combinations

Joe,

The processing that takes place is more manipulation, not summarization. The data in simple form may look like:

Math 1 93 4

Math 2 85 3

Read 1 72 2

Sci 3 52 1

I create standard variables in either a nested file (students nested within years) that look like:

Math_sem1_ss=93

Math_sem1_al=4

Sci_sem3_ss=52

Sci_sem3_al=1

Or in a flat file like (assuming the scores are from 2011):

Math_sem1_ss_11=93

Math_sem1_al_11=4

Sci_sem3_ss_11=52

Sci_sem3_al_11=1

The TEST data file has all sorts of subjects.the user may only want a few (or maybe just 1).

From: Joe Matise [mailto:snoopy369@gmail.com] Sent: Monday, May 02, 2011 8:01 PM To: Jason Schoeneberger Cc: SAS-L@listserv.uga.edu Subject: Re: List Processing and Combinations

I don't fully understand what you're aiming to do with this. What actual processing is going to happen? Is it possible to use a BY statement to produce summarized data without all this macro fun? If possible this should be option #1...

If not, then you can probably add into the proc sql call: proc sql; select distinct cats('%jason(',subject,',',sem,')') into :semcall separated by ' ' from test where subject="&sub."; quit;

Is that your question? I'm not 100% sure what you're asking for help with here in any event, but perhaps that's the right direction...

But again if possible BY group processing is faster and easier. If you're doing some summarizations, you can do

proc means data=test; by subject sem; (...) run; and you get output for each combination of subject and sem that is in the data (and of course you can limit to only certain subjects as you wish).

-Joe

On Mon, May 2, 2011 at 6:29 PM, Jason Schoeneberger <jschoeneberger@carolina.rr.com> wrote:

Hi All,

I'm working on a macro to be used by other users, trying to create some processing where they supply some parameters and the macro yields some summarized data. Below I've created some simple data as an example, along with the beginnings of the code I'm using to handle the list of variables. My problem is this: there is a large data file/table called test that the macro grabs information from. The user supplies the subject they are interested in, and then a series of different macro routines within the eoc macro processing and manipulate data, restructuring, etc. I need to somehow read the SEM values from the actual table for EACH subject, and use those values to create a call to a macro that represents every combination, given the data. So ultimately, I might want a set of calls that look like:

%jason (math,1):

%jason (math,2):

%jason (math,3):

%jason (read,1):

%jason (sci,1):

%jason (sci,2):

I'm stuck on how to get here, and I'm looking for some thoughts on how to do this. If my example or problem isn't clear, let me know and I'll expand some. Thanks in advance for any help.

options nodate;

data test;

input subject $ sem @@;

cards;

math 1

math 2

math 3

read 1

sci 2

sci3

;

run;

*options mlogic;

%macro eoc (subjects);

**this goes through the list of subjects supplied by the user;

%local i subject n;

%let i = 1;

%let subject = %scan(&subjects, &i);

%do %while (&subject^=);

%let fsemcall&i=%nrstr(%eocsem)%str((&subject););

%let i = %eval(&i + 1);

%let subject = %scan(&subjects, &i);

%let n = %eval(&i - 1);

%end;

**macro to generate list of subject-specific semesters;

%macro eocsem(sub,sub2);

%global &sub2._sem;

**create data file to obtain list of semesters;

proc sql noprint;

select unique(sem) into : &sub2._sem separated by ' '

from test

where (subject="&sub") ;

quit;

%mend eocsem;

**this will supply the macro call to cycle through fmerg macro for each subject;

%do i=1 %to &n;

%unquote(&&fsemcall&i);

%end;

%put _all_;

%mend eoc;

*%macro eoc (subjects);

%eoc (subjects=math read sci);


Back to: Top of message | Previous page | Main SAS-L page