<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Write all credits and grades on 1 row for each student in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/829029#M327514</link>
    <description>&lt;P&gt;Give a try and happy to help. Look into a COMPUTE statement with a BREAK statement as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://excursive.org/sas/ProcReportPaper.pdf" target="_blank"&gt;https://excursive.org/sas/ProcReportPaper.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Aug 2022 14:00:14 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-08-17T14:00:14Z</dc:date>
    <item>
      <title>Write all credits and grades on 1 row for each student</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/828795#M327413</link>
      <description>&lt;P&gt;I HAVE (see the import file have.csv) and this code to import it:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.HAVE;
/* change path to fit your setup! */
  infile "D:\GRADES\have.csv" 
	delimiter = "|"
	missover 
	dsd
	firstobs=2;
 
	informat ID $20.;
	informat COURSE $20.;
	informat DATE YYMMDD10.;
	informat EARNED_CREDIT $20.;
	informat CRS_COMP $20.;
	informat C_GRADE $20.;
	informat N_GRADE 4.;
	informat CREDIT 4.;

	format ID $20.;
	format COURSE $20.;
	format DATE YYMMDD10.;
	format EARNED_CREDIT $20.;
	format CRS_COMP $20.;
	format C_GRADE $20.;
	format N_GRADE 4.;
	format CREDIT 4.;

	input
	ID
	COURSE 
	DATE 
	EARNED_CREDIT
	CRS_COMP
	C_GRADE
	N_GRADE
	CREDIT
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I WANT:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Credits (TotalCreditEarned) and ALL Grades (as (chance_1,Chance_2,Chance_n) in each column apart) of each student to show up like this in a proc print.&lt;/P&gt;
&lt;P&gt;How do I do this?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="WANT.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/74453iC7392F4DAB001219/image-size/medium?v=v2&amp;amp;px=400" role="button" title="WANT.png" alt="WANT.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 08:37:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/828795#M327413</guid>
      <dc:creator>SAS_Question</dc:creator>
      <dc:date>2022-08-16T08:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Write all credits and grades on 1 row for each student</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/828802#M327417</link>
      <description>&lt;P&gt;Try proc report: group by student and course, sum for credit and across for n_grade.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 10:26:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/828802#M327417</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-08-16T10:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Write all credits and grades on 1 row for each student</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/828829#M327431</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.HAVE;
/* change path to fit your setup! */
  infile "c:\temp\have.csv" 
 delimiter = "|"
 missover 
 dsd
 firstobs=2;
 
 informat ID $20.;
 informat COURSE $20.;
 informat DATE DDMMYY10.;
 informat EARNED_CREDIT $20.;
 informat CRS_COMP $20.;
 informat C_GRADE $20.;
 informat N_GRADE 4.;
 informat CREDIT 4.;

 format ID $20.;
 format COURSE $20.;
 format DATE YYMMDD10.;
 format EARNED_CREDIT $20.;
 format CRS_COMP $20.;
 format C_GRADE $20.;
 format N_GRADE 4.;
 format CREDIT 4.;

 input
 ID
 COURSE 
 DATE 
 EARNED_CREDIT
 CRS_COMP
 C_GRADE
 N_GRADE
 CREDIT
;
run;

data part1(index=(x=(id course)));
 set have;
 if CREDIT=0;
run;
proc transpose data=part1 out=part2(drop=_: course) prefix=Chance_;
by id course;
var C_GRADE;
run;

data part3(index=(x=(id course)) rename=(CREDIT=TotalCreditEarned));
 set have;
 if CREDIT ne 0;
 keep id course CREDIT;
run;


data want;
 merge part3 part2;
 by id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Aug 2022 12:30:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/828829#M327431</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-08-16T12:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Write all credits and grades on 1 row for each student</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/828881#M327452</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;.. you really deserve a diamond as sharp as your Knowledge for your programming skills! Wow!!&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I'm waiting with accepting your working solution though.&lt;/P&gt;
&lt;P&gt;Because I'm really eager to learn more about proc report and how to solve this HAVE data of mine with a single Proc Report...&lt;/P&gt;
&lt;P&gt;Thanks for your answer though. That's a really neat solution too!!!!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;thank you for the tip. Can you give an example of this Proc Report you are mentioning? Because I'm still learning this proc I would really love to see an example of how you would do it. Thanks a lot in advance!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 16:28:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/828881#M327452</guid>
      <dc:creator>SAS_Question</dc:creator>
      <dc:date>2022-08-16T16:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: Write all credits and grades on 1 row for each student</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/828891#M327456</link>
      <description>&lt;P&gt;The solution depends on what type of &lt;STRONG&gt;output&lt;/STRONG&gt; you want. If you want only displayed output, piped to Excel/PDF/WORD use PROC REPORT. If you want it in that format in a data set to do further analysis, then&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;solution is the one you want.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 16:52:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/828891#M327456</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-08-16T16:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: Write all credits and grades on 1 row for each student</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/828908#M327459</link>
      <description>I would love to see the first output you mentioned &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; !! Thank you for your clarification on this matter!</description>
      <pubDate>Tue, 16 Aug 2022 17:58:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/828908#M327459</guid>
      <dc:creator>SAS_Question</dc:creator>
      <dc:date>2022-08-16T17:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: Write all credits and grades on 1 row for each student</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/828934#M327468</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/195211"&gt;@SAS_Question&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I would love to see the first output you mentioned &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; !! Thank you for your clarification on this matter!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Examples of using ACROSS in PROC REPORT.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/Proc-report-ACROSS/td-p/433732" target="_blank"&gt;https://communities.sas.com/t5/SAS-Procedures/Proc-report-ACROSS/td-p/433732&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 21:10:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/828934#M327468</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-08-16T21:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: Write all credits and grades on 1 row for each student</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/828935#M327469</link>
      <description>&lt;P&gt;Here's a starter. Based on this, I suspect you have to do some more data wrangling to get the PROC REPORT exactly correct.&lt;/P&gt;
&lt;P&gt;FYI - I had to change the import step to correctly read the data, the Date informat was incorrect and c_grade was being read in as a character when it should be numeric. I'm assuming....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.HAVE;
/* change path to fit your setup! */
  infile "/home/fkhurshed/Demo1/HAVE.csv" 
	delimiter = "|"
	missover 
	dsd
	firstobs=2;
 
	informat ID $20.;
	informat COURSE $20.;
	informat DATE DDMMYY10.;
	informat EARNED_CREDIT $20.;
	informat CRS_COMP $20.;
	informat C_GRADE commax.;
	informat N_GRADE 4.;
	informat CREDIT 4.;

	format ID $20.;
	format COURSE $20.;
	format DATE YYMMDD10.;
	format EARNED_CREDIT $20.;
	format CRS_COMP $20.;
	format C_GRADE 8.2;
	format N_GRADE 4.;
	format CREDIT 4.;

	input
	ID
	COURSE 
	DATE 
	EARNED_CREDIT
	CRS_COMP
	C_GRADE
	N_GRADE
	CREDIT
;
run;

proc sort data=have;
by id course;
run;

data have_indexed;
set have;
by id course;
*where credit ne 0;
if first.course or first.id then chance=1;
else chance+1;
run;


proc report data=have_indexed;
*where credit ne 0;
column ID course credit (chance , c_grade)  ;
define id / group;
define course /group;
define chance / across ;
define credit / sum;
define c_grade / '' sum format=8.1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Aug 2022 21:12:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/828935#M327469</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-08-16T21:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Write all credits and grades on 1 row for each student</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/828994#M327493</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;!!! That's what I mean. Only... 1 addition please..if you don't mind..?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I get a sum (of 25 CREDITS for each student) on these 2 places of the CREDITS? Can you point me out in the right direction? TiA!!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS_Question_0-1660735646773.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/74487i0B550A74C48E7C06/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SAS_Question_0-1660735646773.png" alt="SAS_Question_0-1660735646773.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 11:28:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/828994#M327493</guid>
      <dc:creator>SAS_Question</dc:creator>
      <dc:date>2022-08-17T11:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: Write all credits and grades on 1 row for each student</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/829029#M327514</link>
      <description>&lt;P&gt;Give a try and happy to help. Look into a COMPUTE statement with a BREAK statement as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://excursive.org/sas/ProcReportPaper.pdf" target="_blank"&gt;https://excursive.org/sas/ProcReportPaper.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 14:00:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-all-credits-and-grades-on-1-row-for-each-student/m-p/829029#M327514</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-08-17T14:00:14Z</dc:date>
    </item>
  </channel>
</rss>

