{"id":3879,"date":"2023-07-15T00:41:34","date_gmt":"2023-07-15T00:41:34","guid":{"rendered":"https:\/\/statorials.org\/it\/sas-controlla-se-il-set-di-dati-esiste\/"},"modified":"2023-07-15T00:41:34","modified_gmt":"2023-07-15T00:41:34","slug":"sas-controlla-se-il-set-di-dati-esiste","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/sas-controlla-se-il-set-di-dati-esiste\/","title":{"rendered":"Come verificare se il set di dati esiste in sas (con esempio)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">\u00c8 possibile utilizzare la seguente macro in SAS per verificare rapidamente se esiste un set di dati:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #0000ff;\">%macro<\/span> check_exists(data);\n   <span style=\"color: #3366ff;\">%if<\/span> <span style=\"color: #3366ff;\">%sysfunc<\/span> ( <span style=\"color: #3366ff;\">exist<\/span> (&amp;data.)) <span style=\"color: #3366ff;\">%then<\/span> <span style=\"color: #3366ff;\">%do<\/span> ;\n      <span style=\"color: #3366ff;\">%put<\/span> Dataset Exists;\n   <span style=\"color: #3366ff;\">%end<\/span> ;\n   <span style=\"color: #3366ff;\">%else<\/span> <span style=\"color: #3366ff;\">%do<\/span> ;\n      <span style=\"color: #3366ff;\">%put<\/span> Dataset Does Not Exist;\n   <span style=\"color: #3366ff;\">%end<\/span> ;\n<span style=\"color: #0000ff;\">%mend<\/span> check_exists;\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Quando si esegue questa macro, restituisce &#8220;Il set di dati esiste&#8221; se esiste un set di dati.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Altrimenti restituir\u00e0 &#8220;Non esiste&#8221;.<\/span><\/p>\n<p> <span style=\"color: #000000;\">L&#8217;esempio seguente mostra come utilizzare questa macro nella pratica.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Esempio: verificare se il set di dati esiste in SAS<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Supponiamo di creare il seguente set di dati in SAS chiamato <strong>data1<\/strong> :<\/span><\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #800080;\"><span style=\"color: #000000;\"><span style=\"color: #008000;\">\/*create dataset*\/\n<\/span><span style=\"color: #800080;\">data<\/span> data1;\n    <span style=\"color: #3366ff;\">input<\/span> hours score;\n    <span style=\"color: #3366ff;\">datalines<\/span> ;\n1 64\n2 66\n4 76\n5 73\n5 74\n6 81\n6 83\n7 82\n8 80\n10 88\n;\n<span style=\"color: #800080;\">run<\/span> ;\n\n<span style=\"color: #008000;\">\/*view dataset*\/\n<\/span><span style=\"color: #800080;\">proc print<\/span> <span style=\"color: #3366ff;\">data<\/span> =data1;<\/span><\/span><\/strong><\/span> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-31264 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/macro1.jpg\" alt=\"\" width=\"167\" height=\"281\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Possiamo definire la seguente macro per verificare se esiste un set di dati:<\/span><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #0000ff;\">%macro<\/span> check_exists(data);\n   <span style=\"color: #3366ff;\">%if<\/span> <span style=\"color: #3366ff;\">%sysfunc<\/span> ( <span style=\"color: #3366ff;\">exist<\/span> (&amp;data.)) <span style=\"color: #3366ff;\">%then<\/span> <span style=\"color: #3366ff;\">%do<\/span> ;\n      <span style=\"color: #3366ff;\">%put<\/span> Dataset Exists;\n   <span style=\"color: #3366ff;\">%end<\/span> ;\n   <span style=\"color: #3366ff;\">%else<\/span> <span style=\"color: #3366ff;\">%do<\/span> ;\n      <span style=\"color: #3366ff;\">%put<\/span> Dataset Does Not Exist;\n   <span style=\"color: #3366ff;\">%end<\/span> ;\n<span style=\"color: #0000ff;\">%mend<\/span> check_exists;<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Possiamo quindi eseguire questa macro per verificare se esiste il set di dati chiamato <strong>data1<\/strong> :<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008000;\">\/*check if dataset called data1 exists*\/\n<\/span><span style=\"color: #800080;\">%check_exists<\/span> (data1);\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Quando visualizziamo il registro, possiamo vedere che la macro restituisce Does Exist poich\u00e9 <strong>data1<\/strong> esiste:<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-31265 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/macro2.jpg\" alt=\"\" width=\"503\" height=\"102\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Supponiamo ora di eseguire anche la macro per verificare se esiste un set di dati chiamato <strong>data2<\/strong> :<\/span><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008000;\">\/*check if dataset called data2 exists*\/\n<\/span><span style=\"color: #800080;\">%check_exists<\/span> (data2);<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Quando guardiamo il log, possiamo vedere che la macro restituisce Does Not Exist poich\u00e9 un set di dati chiamato <strong>data2<\/strong> non \u00e8 mai stato creato.<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-31266 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/macro3.jpg\" alt=\"\" width=\"503\" height=\"106\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\"><strong>Nota<\/strong> : \u00e8 possibile trovare la documentazione completa della funzione <strong>EXIST<\/strong> in SAS <a href=\"https:\/\/documentation.sas.com\/doc\/en\/pgmsascdc\/9.4_3.2\/lefunctionsref\/p1thpm9d6f5itan1c37zh8uz273z.htm\" target=\"_blank\" rel=\"noopener\">qui<\/a> .<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">I seguenti tutorial spiegano come eseguire altre attivit\u00e0 comuni in SAS:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/it\/sas-eliminare-il-set-di-dati\/\" target=\"_blank\" rel=\"noopener\">Come eliminare i set di dati in SAS<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/sas-rinominare-le-variabili\/\" target=\"_blank\" rel=\"noopener\">Come rinominare le variabili in SAS<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/senza-creare-nuove-variabili\/\" target=\"_blank\" rel=\"noopener\">Come creare nuove variabili in SAS<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00c8 possibile utilizzare la seguente macro in SAS per verificare rapidamente se esiste un set di dati: %macro check_exists(data); %if %sysfunc ( exist (&amp;data.)) %then %do ; %put Dataset Exists; %end ; %else %do ; %put Dataset Does Not Exist; %end ; %mend check_exists; Quando si esegue questa macro, restituisce &#8220;Il set di dati esiste&#8221; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Come verificare se esiste un set di dati in SAS (con esempio) - Statorials<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come verificare se esiste un set di dati in SAS, con un esempio.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/it\/sas-controlla-se-il-set-di-dati-esiste\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come verificare se esiste un set di dati in SAS (con esempio) - Statorials\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come verificare se esiste un set di dati in SAS, con un esempio.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/sas-controlla-se-il-set-di-dati-esiste\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-15T00:41:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/macro1.jpg\" \/>\n<meta name=\"author\" content=\"Benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minuto\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/it\/sas-controlla-se-il-set-di-dati-esiste\/\",\"url\":\"https:\/\/statorials.org\/it\/sas-controlla-se-il-set-di-dati-esiste\/\",\"name\":\"Come verificare se esiste un set di dati in SAS (con esempio) - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-15T00:41:34+00:00\",\"dateModified\":\"2023-07-15T00:41:34+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come verificare se esiste un set di dati in SAS, con un esempio.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/sas-controlla-se-il-set-di-dati-esiste\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/sas-controlla-se-il-set-di-dati-esiste\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/sas-controlla-se-il-set-di-dati-esiste\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come verificare se il set di dati esiste in sas (con esempio)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/it\/#website\",\"url\":\"https:\/\/statorials.org\/it\/\",\"name\":\"Statorials\",\"description\":\"La tua guida all&#039;alfabetizzazione statistica!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/it\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"it-IT\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\",\"name\":\"Benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Benjamin anderson\"},\"description\":\"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9\",\"sameAs\":[\"https:\/\/statorials.org\/it\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Come verificare se esiste un set di dati in SAS (con esempio) - Statorials","description":"Questo tutorial spiega come verificare se esiste un set di dati in SAS, con un esempio.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/statorials.org\/it\/sas-controlla-se-il-set-di-dati-esiste\/","og_locale":"it_IT","og_type":"article","og_title":"Come verificare se esiste un set di dati in SAS (con esempio) - Statorials","og_description":"Questo tutorial spiega come verificare se esiste un set di dati in SAS, con un esempio.","og_url":"https:\/\/statorials.org\/it\/sas-controlla-se-il-set-di-dati-esiste\/","og_site_name":"Statorials","article_published_time":"2023-07-15T00:41:34+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/macro1.jpg"}],"author":"Benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Benjamin anderson","Est. reading time":"1 minuto"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/it\/sas-controlla-se-il-set-di-dati-esiste\/","url":"https:\/\/statorials.org\/it\/sas-controlla-se-il-set-di-dati-esiste\/","name":"Come verificare se esiste un set di dati in SAS (con esempio) - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-15T00:41:34+00:00","dateModified":"2023-07-15T00:41:34+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come verificare se esiste un set di dati in SAS, con un esempio.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/sas-controlla-se-il-set-di-dati-esiste\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/sas-controlla-se-il-set-di-dati-esiste\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/sas-controlla-se-il-set-di-dati-esiste\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come verificare se il set di dati esiste in sas (con esempio)"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/it\/#website","url":"https:\/\/statorials.org\/it\/","name":"Statorials","description":"La tua guida all&#039;alfabetizzazione statistica!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/it\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"it-IT"},{"@type":"Person","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae","name":"Benjamin anderson","image":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Benjamin anderson"},"description":"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9","sameAs":["https:\/\/statorials.org\/it"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/3879"}],"collection":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/comments?post=3879"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/3879\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=3879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=3879"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=3879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}