09-01-2016
mich_ard
Fluorite | Level 6
Member since
03-01-2016
- 11 Posts
- 2 Likes Given
- 0 Solutions
- 0 Likes Received
-
Latest posts by mich_ard
Subject Views Posted 3338 09-01-2016 02:13 PM 1783 08-17-2016 06:22 PM 1784 08-17-2016 05:54 PM 1791 08-17-2016 05:05 PM 1806 08-17-2016 04:14 PM 1288 03-18-2016 05:17 PM 1327 03-18-2016 03:31 PM 1314 03-18-2016 03:27 PM 1381 03-04-2016 02:50 PM 1138 03-01-2016 01:04 PM -
Activity Feed for mich_ard
- Posted using two SET statements to combine 2 datasets on SAS Programming. 09-01-2016 02:13 PM
- Posted Re: A question about using "output out=" on SAS Programming. 08-17-2016 06:22 PM
- Posted Re: A question about using "output out=" on SAS Programming. 08-17-2016 05:54 PM
- Posted Re: A question about using "output out=" on SAS Programming. 08-17-2016 05:05 PM
- Posted A question about using "output out=" on SAS Programming. 08-17-2016 04:14 PM
- Posted Re: A simple question about reading raw data in SAS on SAS Programming. 03-18-2016 05:17 PM
- Posted Re: Simple Date Informat Question on SAS Programming. 03-18-2016 03:31 PM
- Liked Re: Simple Date Informat Question about date informat for ballardw. 03-18-2016 03:31 PM
- Liked Re: Simple Date Informat Question for MichelleHomes. 03-18-2016 03:31 PM
- Posted A simple question about reading raw data in SAS on SAS Programming. 03-18-2016 03:27 PM
- Posted Simple Date Informat Question on SAS Programming. 03-04-2016 02:50 PM
- Posted Re: in SAS, letter case really doesn't matter? on SAS Programming. 03-01-2016 01:04 PM
- Posted in SAS, letter case really doesn't matter? on SAS Programming. 03-01-2016 12:48 PM
-
Posts I Liked
Subject Likes Author Latest Post 1 1
09-01-2016
02:13 PM
Hi everyone, I got a question about using 2 SETs to combine 2 datasets. My question came from the Little SAS Book (5th ed) on page 12/27: Combining a Grand Total with the Original Data. To make it easier to understand, I copy the whole programming: A distributor of athletic shoes is considering doing a special promotion for the top-selling styles. The vice-president of marketing asks you to produce a report showing the percentage of total sales for each style. For each style of shoe the raw data file contains the style name, type of exercise, and sales for the last quarter: Max Flight running 1930 Zip Fit Leather walking 2250 Zoom Airborne running 4150 Light Step walking 1130 Max Step Woven walking 2230 Zip Sneak c-train 1190 Here is the program: DATA shoes; INFILE 'c:\MyRawData\Shoesales.dat'; INPUT Style $ 1-15 ExerciseType $ Sales; RUN; * Output grand total of sales to a data set and print; PROC MEANS NOPRINT DATA = shoes; VAR Sales; OUTPUT OUT = summarydata SUM(Sales) = GrandTotal; RUN; PROC PRINT DATA = summarydata; TITLE 'Summary Data Set'; RUN; * Combine the grand total with the original data; DATA shoesummary; IF _N_ = 1 THEN SET summarydata; SET shoes; Percent = Sales / GrandTotal * 100; RUN; PROC PRINT DATA = shoesummary; VAR Style ExerciseType Sales GrandTotal Percent; TITLE 'Overall Sales Share'; RUN; ---------------------- My question is in the last part (Combine the grand total with the original data): DATA shoesummary; IF _N_ = 1 THEN SET summarydata; SET shoes; Percent = Sales / GrandTotal * 100; I do'nt quite understand why "IF _N_ = 1 THEN SET summarydata" is used here (although it works beautifully), why don't just simply use my simple version like this: DATA shoesummary; SET summarydata; SET shoes; Percent = Sales / GrandTotal * 100; Of course, my simple version does not work. The dataset summarydata has only 1 line of observation, "IF _N_ = 1 THEN SET summarydata" will copy the whole dataset, my simple version will also copy the whole dataset. They are supposed to be the same, in my opinion, but actually NOT. Then what's the difference between them? is there any special reason to use "IF _N_ = 1 THEN SET summarydata" ? (if this question sounds to be too silly, please forgive me) Thanks.
... View more
08-17-2016
06:22 PM
yes, i tried it, works just like proc means(+noprint). thanks a lot.
... View more
08-17-2016
05:05 PM
Thank Reeza and Shmuel, your suggestions seem right, but still have some questions: 1, when I use PROC CONTENTS to check variable names, no "total sales" was found indeed, only saw "sales", but the dataset "sashelp.shoes" in my computer does clearly show "Total Sales" instead of "Sales" (see the attached picture 1). 2, when I used following codes as you suggested, it seemed working, which shows a table format exactly as I want, but the problem remains: "Total Sales" again, not the one I expected (ie, total_regional_sales) (picture 2). proc means data= sashelp.shoes ; var sales ; by region; output out=Regional_sales SUM(sales)=total_regional_sales; run; this problem seems bizzare, "Total Sales" seems very dominate in my computer, I wonder if my computer is virus infected. any more idea? thanks again. Mike
... View more
08-17-2016
04:14 PM
Hi I got a problem when I practise using "output out=" . The dataset I'm using is sashelp.shoes, which is about shoes sale in the world, and contains many different regions (africa, asia,europe ...). I want to make a table which can summerize the sales based on regions (africa, asia,europe ...), this is my codes: proc means data= sashelp.shoes ; var total sales ; by region; output out=Regional_sales SUM(total sales)=reginal_sales; run; but it didn't work, the log says: ERROR: Variable TOTAL not found. why ? thanks.
... View more
03-18-2016
05:17 PM
thanks for your reply. What you said is very helpful for me to understand how to use informat. My question still remains: why the output result is: 22
4444
55555 mike,
... View more
03-18-2016
03:27 PM
Hi everyone, I got a question about reading raw data: ----+----1----+----2
1
22
333
4444
55555 I used following codes with a fixed width of 5. data numbers;
infile 'external-file';
input testnum 5.;
run; the output result is: 22
4444
55555 I don't understand this output. First line has only 1 digit, plus 2nd line (2 digits), still not enough, right? I guess it goes to 3 line, ok! but why it picks up only 22, instead of pick them up together? (eg. 12233). For the remaining 2 lines it's the same way to read, it should get 44445. So my expectation is: 12234 44445 am I correct? or where is the problem? Thanks. Mike,
... View more
03-04-2016
02:50 PM
Hello everyone,
I'm just started learning SAS, and got a simple question about date informat (don't know if it's too simple or too stupid).
Since ANYDTDTEw informat can read any date styles, why does SAS have so many other date informats, like mmddyy, ddmmyy,date, julian...)? is it nevessary to keep them? In my opinion, actually very few people like to use the simple way (ANYDTDTEw), is there any reason for this?
thanks,
... View more
03-01-2016
01:04 PM
thank Reeza for quick reply, your answer works. I confused code case and value case. I'm a newbie.
... View more
03-01-2016
12:48 PM
Hi guys, I just got a question, need your help: letter case in SAS seems making difference, at least in the case of "if...(then)". Look at this example: data _t_; input ID Name$ bloodtype$ Weight; if bloodtype='a'; cards; 3 kelly a 120 4 brown A 200 ; run; the result has only 1 line (3 kelly a 120). if I change 'a' to 'A', then I get another line (4 brown A 200). both didn't give me a result of all 2 lines. does this mean, in some cases, letter case matters? thanks,
... View more