tag:blogger.com,1999:blog-7958828565254404797.post5321002222816953216..comments2024-03-28T07:44:59.527-07:00Comments on ListenData: Advanced SAS Interview Questions and AnswersDeepanshu Bhallahttp://www.blogger.com/profile/09802839558125192674noreply@blogger.comBlogger33125tag:blogger.com,1999:blog-7958828565254404797.post-26693781859593756432023-08-18T00:11:55.924-07:002023-08-18T00:11:55.924-07:00Hi Deepanshu, I think a small thing need to be upd...Hi Deepanshu, I think a small thing need to be updated in merge syntax for the Question No. 7<br />Data want;<br />merge x(in=a) y(in=b drop = ID);<br />by managerID;<br />if a;<br />run;<br />we need to drop ID to get the desired resultKapilhttps://www.blogger.com/profile/07987977863429051897noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-18705242293194672162021-10-11T13:18:12.951-07:002021-10-11T13:18:12.951-07:00Nice Post... this will help mainly for Experience ...Nice Post... this will help mainly for Experience persons.Anonymoushttps://www.blogger.com/profile/17834285955205757245noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-49623477494882384922021-05-03T04:21:09.858-07:002021-05-03T04:21:09.858-07:00data xyz;
input x $;
cards;
AA
AA
AA
BB
BB
;
run;
...data xyz;<br />input x $;<br />cards;<br />AA<br />AA<br />AA<br />BB<br />BB<br />;<br />run;<br /><br />**// incremental value by group ///******;<br />proc sql;<br /> select *, case when x="AA" then 1 <br /> else 1+1 end as n from xyz;quit;katehttps://www.blogger.com/profile/14234847808779710242noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-7554529596439291982020-09-10T06:53:22.475-07:002020-09-10T06:53:22.475-07:00Post Questions based on, creating datasets based o...Post Questions based on, creating datasets based on dates using macrosAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-37769360152402312022020-06-09T21:55:13.707-07:002020-06-09T21:55:13.707-07:00Hi Deepanshu,
Do you provide coachings for SAS?
i...Hi Deepanshu,<br /><br />Do you provide coachings for SAS?<br />if yes then let me know how can i connect with you.Deepanshuhttps://www.blogger.com/profile/11732740342926247406noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-65249964890144434122019-09-20T00:09:39.443-07:002019-09-20T00:09:39.443-07:00I have data set
Id test$ results
101 WBC 90
101 R...I have data set <br />Id test$ results<br />101 WBC 90<br />101 RBC 103<br />101 alc 100<br />101 WBC 92<br />101 alc 93<br />101 RBC 92<br />101 WBC 96<br />101 RBC 92<br />101 alc 93 <br />I need this one sub ,one test second highest value Anonymoushttps://www.blogger.com/profile/06129689660779754697noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-51508071080334872262018-08-16T23:22:15.831-07:002018-08-16T23:22:15.831-07:00its not the error it is the note.
try this on
...its not the error it is the note. <br /><br />try this on <br /><br />Data sales ;<br />input sales_id qty item $ sales_date order_type;<br />informat sales_date date9.;<br />format sales_date date9.;<br />cards;<br />101 2 Pdrive 25jun2005 1<br />101 3 Pdrive 25jul2005 1<br />101 4 Mobile 25aug2005 2<br />101 6 Mobile 25jun2004 2<br />101 8 Mobile 25jul2004 2<br />101 2 Mobile 25aug2004 2<br />102 2 Pdrive 25jun2005 1<br />102 3 Mobile 25jul2005 2<br />102 4 Laptop 25aug2005 3<br />102 6 Mobile 25jun2004 2<br />102 8 Mobile 25jul2004 2<br />102 2 Mobile 25aug2004 2<br />103 2 Laptop 25jun2005 3<br />103 3 Mobile 25jul2005 2<br />103 4 Laptop 25aug2005 3<br />103 6 Mobile 25jun2004 2<br />103 8 Mobile 25jul2004 2<br />103 2 Laptop 25aug2004 3<br />;<br />;<br />run;<br /><br /><br /><br />%macro freq(year,type);<br />proc sql;<br />select year,quant,order_type from (<br />select distinct year(sales_date) as year,order_type,sum(qty) as quant from sales group by order_type) <br />where year=&year and order_type=&type;<br />quit;<br />%mend;<br /><br />%freq(2005,1);Shivam arorahttps://www.blogger.com/profile/13087323998357691338noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-6435252500286964012018-08-16T23:13:32.991-07:002018-08-16T23:13:32.991-07:00Short code for question 30....
options mlogic sym...Short code for question 30....<br /><br />options mlogic symbolgen mprint;<br /><br />%macro split(ds,n);<br /><br />%do i=1 %to &n;<br /> <br />data data&i. ;<br />set &ds. nobs=nobs;<br />f=ceil(_n_*&n/nobs);<br /><br />if f=&i then output data&i;<br /><br />run;<br /><br />%end;<br /><br />%mend();<br /><br />%split( ds=sasuser.cargorev,n=2);Shivam arorahttps://www.blogger.com/profile/13087323998357691338noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-55193683255204723572018-05-31T09:29:55.695-07:002018-05-31T09:29:55.695-07:00Hello,
When I tried to execute the macro to print ...Hello,<br />When I tried to execute the macro to print the freq of orders placed based on type and year,I am getting below error.Please help.<br /><br />%macro freq(year=,type=);<br />proc sql;<br />select total_qty from(<br />select year(Order_date) as year ,order_type ,sum(quantity) as total_qty from Vani_Sas.sales_data<br />group by Order_type)<br />where year=&year and order_type=&type;<br />quit;<br />%mend;<br />%freq(year=2005,type=1);<br /><br />NOTE: The query requires remerging summary statistics back with the original data.<br /> NOTE: No rows were selected.Vaishnavihttps://www.blogger.com/profile/12079385694343652701noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-33145379056281605662018-02-28T12:14:25.225-08:002018-02-28T12:14:25.225-08:00Hi Deepanshu,
Awesome explanation and cleared so ...Hi Deepanshu,<br /><br />Awesome explanation and cleared so many doubts here.<br />Can you please tell me what are the companies that offer Jobs based on SAS in Hyderabad?<br /><br /><br />Thank you.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-43819744107317490922017-12-01T23:45:33.337-08:002017-12-01T23:45:33.337-08:001. Consider you have Sales Data and a variab...1. Consider you have Sales Data and a variable Order_date is the Date of Order Placed. <br />Write a Macro that will Display the Report of all the Sales Conducted on Daily Basis ? <br />;<br /><br />Data Sales;<br />input Product $ sales_id order_id ;<br />cards;<br />Mobile 101 201<br />Laptop 102 202<br />Mobile 103 203<br />Laptop 104 304<br />;<br />run;<br /><br />Data order;<br />input order_date order_id;<br />informat order_date date9.;<br />format order_date date9.;<br />cards;<br />01DEC2017 201<br />02DEC2017 202<br />02DEC2017 203<br />01DEC2017 204<br />;<br />run;<br /><br /><br />%let daily=%sysfunc(today());<br /><br />%put &daily;<br /><br />proc sql;<br />select count(a.product) into:Total_Order from sales as a left join order as b<br />on a.order_id=b.order_id<br />where b.order_date=&daily;<br />quit;<br /><br />%put &Total_Order;<br /><br />Title 'Find the total sales as on &daily is &Total_Order';<br /><br />- 2. Consider Same Sales Data, Write a Macro to get summarized report on any particular year ? <br />Example: I want to run proc means on sales data for the year 2004, may be tomorrow I want to get for 2005 or so. <br /><br />;<br /><br />Data sales_data;<br />input sales_id qty item $ sales_date;<br />informat sales_date date9.;<br />format sales_date date9.;<br />cards;<br />101 2 Mobile 25jun2005<br />101 3 Mobile 25jul2005<br />101 4 Mobile 25aug2005<br />101 6 Mobile 25jun2004<br />101 8 Mobile 25jul2004<br />101 2 Mobile 25aug2004<br />;<br />run;<br /><br />%let year=2005; * Change year as per your requirements;<br /><br />proc sql;<br />select item,total_qty_sales from(<br />select item,year(sales_date) as year,sum(qty) as total_qty_sales from sales_data<br />group by 1,2)<br />where year=&year;<br />quit;<br /><br /><br />3. Consider the Same Sales Data. Suppose you have 3 Types of Orders and a variable Order_type having<br /> values either Type 1 Type 2 or Type 3 for Each Order Placed and you have another variable Quantity, having <br /> the total number of quantities ordered for each order.<br /> Write a Macro to display the frequency of quantity<br /> ordered for given order type in any particular year. <br />Example: If I mention value of year 2004 and type 3, It should display frequency of quantities placed in <br />2004 with type 3 with appropriate title. If I just mention year 2004, It should display frequency of all <br />quantities ordered in 2004 with all types. <br />;<br /><br /><br />Data sales_data;<br />input sales_id qty item $ sales_date order_type;<br />informat sales_date date9.;<br />format sales_date date9.;<br />cards;<br />101 2 Pdrive 25jun2005 1<br />101 3 Pdrive 25jul2005 1<br />101 4 Mobile 25aug2005 2<br />101 6 Mobile 25jun2004 2<br />101 8 Mobile 25jul2004 2<br />101 2 Mobile 25aug2004 2<br />102 2 Pdrive 25jun2005 1<br />102 3 Mobile 25jul2005 2<br />102 4 Laptop 25aug2005 3<br />102 6 Mobile 25jun2004 2<br />102 8 Mobile 25jul2004 2<br />102 2 Mobile 25aug2004 2<br />103 2 Laptop 25jun2005 3<br />103 3 Mobile 25jul2005 2<br />103 4 Laptop 25aug2005 3<br />103 6 Mobile 25jun2004 2<br />103 8 Mobile 25jul2004 2<br />103 2 Laptop 25aug2004 3<br />;<br />;<br />run;<br /><br />%macro freq(year=,type=);<br />proc sql;<br />select item,total_qty from(<br />select item,year(sales_date) as year ,order_type ,sum(qty) as total_qty from sales_data<br />group by 1,2,3)<br />where year=&year and order_type=&type;<br />quit;<br />%mend;<br />%freq(year=2005,type=1);<br />Anonymoushttps://www.blogger.com/profile/12603388662004582299noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-68666206257322017542017-11-29T15:36:10.682-08:002017-11-29T15:36:10.682-08:00please give the answer:
1. Consider you ha...please give the answer:<br /><br />1. Consider you have Sales Data and a variable Order_date is the Date of Order Placed. Write a Macro that will Display the Report of all the Sales Conducted on Daily Basis ? <br /> <br />Example: If today is 01 January 2000, If I call macro today, It shows orders placed on 01 January 2000. If I call same macro on 02 January, It should give Report of orders placed on 02 January. <br /><br />- 2. Consider Same Sales Data, Write a Macro to get summarized report on any particular year ? <br />Example: I want to run proc means on sales data for the year 2004, may be tomorrow I want to get for 2005 or so. <br /><br />- 3. Consider the Same Sales Data. Suppose you have 3 Types of Orders and a variable Order_type having values either Type 1 Type 2 or Type 3 for Each Order Placed and you have another variable Quantity, having the total number of quantities ordered for each order. Write a Macro to display the frequency of quantity ordered for given order type in any particular year. <br />Example: If I mention value of year 2004 and type 3, It should display frequency of quantities placed in 2004 with type 3 with appropriate title. If I just mention year 2004, It should display frequency of all quantities ordered in 2004 with all types. <br /> <br /><br />- 4. Write a Macro to get pdf report of orders placed in range of years with appropriate title? <br />Example: If I select range of years 2003 to 2006, I should get pdf report of orders placed in all these years separately on desktop. <br /><br />- 5. Write a Macro to get a Report for each year and each order type, so we get the mean of total_retail_price in the title ? <br /> <br />Example: Suppose I choose year = 2001 and order_type = 2, It should display orders placed in these parameters and I also want the mean of total_retail_price in the title of the report. <br /><br />Thanks,<br />ShwetaShweta Guptahttps://www.blogger.com/profile/07792250556574514273noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-14415867512459120572017-11-29T15:33:32.649-08:002017-11-29T15:33:32.649-08:00please give the answer:
use data in the Data Shee...please give the answer:<br /><br />use data in the Data Sheet <br />1. Consider you have Sales Data and a variable Order_date is the Date of Order Placed. Write a Macro that will Display the Report of all the Sales Conducted on Daily Basis ? <br /> <br />Example: If today is 01 January 2000, If I call macro today, It shows orders placed on 01 January 2000. If I call same macro on 02 January, It should give Report of orders placed on 02 January. <br /> <br /> proc print data=Sales_Data; <br /> <br /> where Order_date='01January2000'd; <br /> <br /> title “Below are the details of Sales data for 01-January-2000”; <br /> <br /> Run; <br /> <br /> <br />2. Consider Same Sales Data, Write a Macro to get summarized report on any particular year ? <br />Example: I want to run proc means on sales data for the year 2004, may be tomorrow I want to get for 2005 or so. <br /> <br /> proc print data=Sales_Data; <br /> <br /> where Order_date='2004'd; <br /> <br /> Run; <br /> <br /> <br />3. Consider the Same Sales Data. Suppose you have 3 Types of Orders and a variable Order_type having values either Type 1 Type 2 or Type 3 for Each Order Placed and you have another variable Quantity, having the total number of quantities ordered for each order. Write a Macro to display the frequency of quantity ordered for given order type in any particular year. <br />Example: If I mention value of year 2004 and type 3, It should display frequency of quantities placed in 2004 with type 3 with appropriate title. If I just mention year 2004, It should display frequency of all quantities ordered in 2004 with all types. <br /> <br /> <br />4. Write a Macro to get pdf report of orders placed in range of years with appropriate title? <br />Example: If I select range of years 2003 to 2006, I should get pdf report of orders placed in all these years separately on desktop. <br /> <br /> <br /> <br />5. Write a Macro to get a Report for each year and each order type, so we get the mean of total_retail_price in the title ? <br /> <br />Example: Suppose I choose year = 2001 and order_type = 2, It should display orders placed in these parameters and I also want the mean of total_retail_price in the title of the report. <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br />6. Suppose you are having live Data, Orders coming from different Countries. Write a Macro to split this master Data into smaller Datasets depending on the Unique value of each countries ? <br /> <br />Example: Suppose I got Order placed from US, CA Today, so I call the macro and it will split the master data into 2 data US and CA having those observation. Tomorrow suppose I have order placed from CH, JP and AU, I call same macro and it will split master data into 3 smaller Data. <br /> <br />Shweta Guptahttps://www.blogger.com/profile/07792250556574514273noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-59125590315139835322017-11-26T02:14:07.472-08:002017-11-26T02:14:07.472-08:00Hi for Q7 i am getting error as variable managerid...Hi for Q7 i am getting error as variable managerid has been defined as both character and numeric . <br /><br />Any suggestions why this is coming?Sweetyhttps://www.blogger.com/profile/14956450694760166830noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-52673322404475711502017-10-04T22:02:14.724-07:002017-10-04T22:02:14.724-07:00please post more real life scenarios
please post more real life scenarios<br />Anonymoushttps://www.blogger.com/profile/11795866164091654054noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-47990259916508470002017-06-13T09:59:05.352-07:002017-06-13T09:59:05.352-07:00Nice Posting Keep on update like this
SAS Advance...Nice Posting Keep on update like this<br /><br /><a href="https://www.maziworld.com/course/sdtm-domain-part1-2" rel="nofollow">SAS Advanced Certification </a><br />Anonymoushttps://www.blogger.com/profile/02406283539885889984noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-13820671220855029962017-05-16T21:56:56.292-07:002017-05-16T21:56:56.292-07:00Excellent question...mostly asked during interview...Excellent question...mostly asked during interview....thanks for writing in such detail.Nikshttps://www.blogger.com/profile/06565384004508965599noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-54992587805586761252017-04-24T11:38:39.408-07:002017-04-24T11:38:39.408-07:00Can you please explain me the 30th question- Split...Can you please explain me the 30th question- Split macro<br />Why do we need the last Do loop? in split macro?<br /><br />Please explain the program.<br />Thanks!Anonymoushttps://www.blogger.com/profile/03249706223554511618noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-4331335582881006152017-04-24T11:36:57.949-07:002017-04-24T11:36:57.949-07:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/03249706223554511618noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-42388202152642536282017-04-14T11:18:26.381-07:002017-04-14T11:18:26.381-07:00I have just written an article on this topic. See ...I have just written an article on this topic. See the link in Q33. Thanks!Deepanshu Bhallahttps://www.blogger.com/profile/09802839558125192674noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-61993237626642780612017-04-09T03:35:34.408-07:002017-04-09T03:35:34.408-07:00using proc content we checkusing proc content we checkAnonymoushttps://www.blogger.com/profile/12603388662004582299noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-65198534951517779022017-04-06T23:26:53.210-07:002017-04-06T23:26:53.210-07:00data new;
old data;
if _n_ >=1 then newvar= non...data new;<br />old data;<br />if _n_ >=1 then newvar= nonempty;<br />else newvar=empty;<br />run;ankita sharmanoreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-23764810758756888932017-04-04T21:36:06.879-07:002017-04-04T21:36:06.879-07:00Also how can we print multiple datasets using sing...Also how can we print multiple datasets using single proc print statement horizontally in output window. Can anyone help hereAnonymoushttps://www.blogger.com/profile/04176889136129550060noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-51510061649371720042017-04-04T21:33:26.242-07:002017-04-04T21:33:26.242-07:00Great Job dude. I have one query..
Q : I need to c...Great Job dude. I have one query..<br />Q : I need to check dataset is empty or not. How can i do this?Anonymoushttps://www.blogger.com/profile/04176889136129550060noreply@blogger.comtag:blogger.com,1999:blog-7958828565254404797.post-53392864006703783732016-12-23T08:42:46.827-08:002016-12-23T08:42:46.827-08:00Q19 explains how to replicate the usage of NODUPKE...Q19 explains how to replicate the usage of NODUPKEY in PROC SQL query.Deepanshu Bhallahttps://www.blogger.com/profile/09802839558125192674noreply@blogger.com