Hi, I am new to SAS and I am trying to input data from the a .txt file. Could someone please help me figure out why the IF-THEN statement only applies to the first row of the data? Thanks! Data: DATA work.condo_ranch;
INFILE '/home/u63748921/SAS 123 Problems/sas123_p13.txt' DSD;
INPUT style $ @;
IF style = 'RANCH' OR style = 'CONDO' THEN INPUT sqfeet bedrooms baths street $ price : dollar10.;
RUN; Output:
... View more
I'm having difficulty writing a piece of SAS code and I'm seeking the most effective approach within SAS. I have a variable named 'type' (with values 1, 2, 3, 4) and client IDs. Essentially, I aim to create another variable called 'modified_type,' which follows these rules: If there's a single unique client ID with only 1 in the 'type' variable, then 'modified_type' should be set to 0. However, if there are multiple client IDs with the same number having 1 in the 'type' variable, 'modified_type' should be set to 1. If there are 2 in the 'type' variable, then 'modified_type' should be set to 2... and so on. I tried using the retain function so something like this: retain modified_type 0; if first.client_id then modified_type = 0; if type = '1' or type = '1st' then modified_type = 1; else if type = '2' or = '2nd' then modified_type = 2; and so on..... but these does seem to retain 0 in the type and for some reason shows as 1. Yea im note sure the best way to do this, a newbie at SAS so would even appreciate the point in the right direction:
... View more
Howdy!
If I specify a font size in SGPLOT, SAS does not seem to actually produce that font size in ODS PDF. It seems to produce some larger font size. Here's example code.
ods pdf file = "M:\test.pdf";
ods graphics on / reset;
title1 height = 12pt font = 'Arial' 'Title 1';
title2 height = 11pt font = 'Arial' 'Title 2';
title3 height = 10pt font = 'Arial' bold 'Title 3';
footnote1 height = 9pt font = 'Arial' 'Footnote 1';
footnote3 height = 8pt font = 'Arial' 'Footnote 2';
proc sgplot data = sasHelp.class; series x = name y = age; xAxis valueAttrs = (family = 'Arial' size = 9.5pt); run;
proc sgplot data = sasHelp.class; series x = name y = age; xAxis valueAttrs = (family = 'Arial' size = 10pt); run;
proc sgplot data = sasHelp.class; series x = name y = age; xAxis valueAttrs = (family = 'Arial' size = 10.5pt); run;
proc sgplot data = sasHelp.class; series x = name y = age; xAxis valueAttrs = (family = 'Arial' size = 11pt); run;
proc sgplot data = sasHelp.class; series x = name y = age; xAxis valueAttrs = (family = 'Arial' size = 11.5pt); run;
proc sgplot data = sasHelp.class; series x = name y = age; xAxis valueAttrs = (family = 'Arial' size = 12pt); run;
ods pdf close;
Title1 comes out as 13 pt. Title2 as 11.5 pt.
Title3 as 11 pt.
Footnote1 as 9.5 pt.
Footnote2 as 9 pt.
The x-axis tick values come out as 9.5, 11, 11, 11.5, 11.5, and 13 pt. respectively.
If I add noGTitle and noGFootnote to the ODS PDF statement, then the font sizes for the titles and footnotes are correct. It seems the problem is with the graphic procedure itself.
I checked the font sizes by copying the text from the PDF and pasting into Word. I am fairly certain the same happens with ODS RTF; I can't paste the text into Word, but eyeballing it, it looks the same. Attached are the PDF and RTF outputs each way, plus a screenshot of the side-by-side comparison of the two RTF files showing that the font without noGTitle definitely is bigger than the font with noGTitle.
Does anyone else also get this? I tested on a SAS session with no other options, custom configuations, etc. but maybe there's still something set on my machine that is messing it up.
Best regards,
Michael
... View more
Hi, I have 2 data sets like below. Data one A 1 A 2 B 1 B 2 Data two A Apple A Peach B Banana I need to join them (Cartesian join), but only join by ID (A and B). This is what I want to get: A 1 Apple A 1 Peach A 2 Apple A 2 Peach B 1 Banana B 2 Banana If I use the below code, proc sql; create table three as select one.* ,two.* from one ,two; quit; What I have got was A 1 Apple A 1 Peach A 1 Banana A 2 Apple A 2 Peach A 2 Banana B 1 Apple B 1 Peach B 1 Banana B 2 Apple B 2 Peach B 2 Banana Is there any way to only join by the ID (A, B)? Thank you very much!
... View more
Hi all - I have a specific report format that I am trying to achieve using PROC REPORT, and I'm getting pretty close, but there's a column subtotal element that I cannot figure out.
I have sales data, summarized by Client, Quarter, and Week. Each quarter contains an arbitrary number of weeks, up to around 13.
I would like to list Client information down the side, with:
Quarters listed across the top,
each Quarter's corresponding Weeks nested underneath,
the table populated with Sales for each Client-Week,
and Grand Totals on the far right and bottom. I've gotten this far on my own just fine.
Where I'm getting stuck is that I'd also like to show Quarterly subtotal columns, at the end of each Quarter. I have tried different variations of "break after" and the like, but I'm just not getting there.
Does anyone in the community have any suggestions? Below is some sample code that represents the progress I've made so far. I've also attached an image showing what I currently "have" versus what I "want." I greatly appreciate any and all help - cheers!
data one; input client_rank client $9. client_id quarter $ weekending sales; datalines; 1 Apple 12345 Q1 20240106 1000 1 Apple 12345 Q1 20240113 2000 1 Apple 12345 Q1 20240127 5000 1 Apple 12345 Q2 20240413 3000 1 Apple 12345 Q2 20240420 4000 1 Apple 12345 Q2 20240427 2000 2 Microsoft 67890 Q1 20240106 3000 2 Microsoft 67890 Q1 20240113 1000 2 Microsoft 67890 Q1 20240127 2500 2 Microsoft 67890 Q2 20240413 4000 2 Microsoft 67890 Q2 20240420 500 2 Microsoft 67890 Q2 20240427 1500 ; run;
proc report data = one nowd; column client_rank client client_id quarter, weekending, sales ("Total" sales=tot); define client_rank / noprint group; define client / "Client" group; define client_id / "Client ID" group; define quarter / " " across; define weekending / " " across nozero; define sales / "Sales" analysis sum format=comma12.0; define tot / "Sales" analysis sum format=comma12.0;
rbreak after / summarize; compute after; client = "Total"; endcomp; define client_rank / order group; run;
... View more